[英]ModuleNotFoundError: No module named 'tensorflow' In Jupyter Notebook
I'm getting this error in my Jupyter Notebook.我的 Jupyter Notebook出现此错误。 The complete error is bellow:
完整的错误如下:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
in
1 import numpy as np # working with data
2 import pandas as pd
----> 3 from keras.layers.core import Dense, Activation, Dropout
4 from keras.layers.recurrent import LSTM
5 from keras.models import Sequential
~\AppData\Local\Programs\Python\Python37-32\lib\site-packages\keras\__init__.py in
1 from __future__ import absolute_import
2
----> 3 from . import utils
4 from . import activations
5 from . import applications
~\AppData\Local\Programs\Python\Python37-32\lib\site-packages\keras\utils\__init__.py in
4 from . import data_utils
5 from . import io_utils
----> 6 from . import conv_utils
7 from . import losses_utils
8 from . import metrics_utils
~\AppData\Local\Programs\Python\Python37-32\lib\site-packages\keras\utils\conv_utils.py in
7 from six.moves import range
8 import numpy as np
----> 9 from .. import backend as K
10
11
~\AppData\Local\Programs\Python\Python37-32\lib\site-packages\keras\backend\__init__.py in
----> 1 from .load_backend import epsilon
2 from .load_backend import set_epsilon
3 from .load_backend import floatx
4 from .load_backend import set_floatx
5 from .load_backend import cast_to_floatx
~\AppData\Local\Programs\Python\Python37-32\lib\site-packages\keras\backend\load_backend.py in
88 elif _BACKEND == 'tensorflow':
89 sys.stderr.write('Using TensorFlow backend.\n')
---> 90 from .tensorflow_backend import *
91 else:
92 # Try and load external backend.
~\AppData\Local\Programs\Python\Python37-32\lib\site-packages\keras\backend\tensorflow_backend.py in
3 from __future__ import print_function
4
----> 5 import tensorflow as tf
6 from tensorflow.python.eager import context
7 from tensorflow.python.framework import device as tfdev
ModuleNotFoundError: No module named 'tensorflow'
In cmd: My python version is:在cmd中:我的python版本是:
C:\Users\casper>python --version
Python 3.6.5 :: Anaconda, Inc.
Anaconda version:蟒蛇版本:
C:\Users\casper>conda --version
conda 4.5.4
In Anaconda Prompt I install Tensorflow like below:在Anaconda Prompt 中,我安装 Tensorflow,如下所示:
conda create -n tensorflow python=3.6
// CPU edition
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow
In Anaconda Prompt : My Tensorflow version is:在Anaconda Prompt 中:我的 Tensorflow 版本是:
(base) C:\Users\casper>activate tensorflow
(tensorflow) C:\Users\casper>python
Python 3.6.2 |Continuum Analytics, Inc.| (default, Jul 20 2017, 12:30:02) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
2020-02-14 19:36:32.468120: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found
2020-02-14 19:36:32.474896: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
>>> tf.__version__
'2.1.0'
>>> tf.__path__
['D:\\Anaconda3\\envs\\tensorflow\\lib\\site-packages\\tensorflow']
It's really the first time I'm working with all these libraries and technologies, I lost the track, I can see all around its different Python versions, It's really messed up for me now.这真的是我第一次使用所有这些库和技术,我迷失了方向,我可以看到所有不同的 Python 版本,现在对我来说真的一团糟。 How could I fix it ?
我怎么能修好呢?
Remember to change to the right kernel.请记住更改为正确的内核。 You can do that in Jupyter Notebook, by pressing
Kernel
.您可以在 Jupyter Notebook 中通过按
Kernel
来执行此操作。 Then select Change kernel
and select your kernel.然后选择
Change kernel
并选择您的内核。
Try running Anaconda as admin (right-click -> run as administrator).尝试以管理员身份运行 Anaconda(右键单击 -> 以管理员身份运行)。 And try these commands as well (taken from the Anaconda Documentation):
并尝试这些命令(取自 Anaconda 文档):
conda create -n tf tensorflow
conda activate tf
You may need to restart you PC.您可能需要重新启动 PC。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.