简体   繁体   English

ModuleNotFoundError:没有名为“tensorflow”的模块

[英]ModuleNotFoundError: No module named 'tensorflow'

I am trying to install tensorflow in vscode(Windows 10) but am getting this error ModuleNotFoundError: No module named 'tensorflow' .我正在尝试在 vscode(Windows 10)中安装 tensorflow 但收到此错误ModuleNotFoundError: No module named 'tensorflow' I have tried setting up a new conda environment, used python 3.5 and have also configured the 'Path' setting but to no avail.我尝试设置一个新的 conda 环境,使用 python 3.5 并且还配置了“路径”设置,但无济于事。 Even though TensorFlow has succesfully installed in my system, whenever I try to import, it doesn't work... Previously I had been using Ubuntu smoothly but getting it on win10_Lite is being very frustrating.尽管 TensorFlow 已成功安装在我的系统中,但每当我尝试导入时,它都不起作用......以前我一直在顺利使用 Ubuntu 但在win10_Lite上安装它非常令人沮丧。 Any help is appreciated...任何帮助表示赞赏...

THIS IS MY TEST CODE:-这是我的测试代码:-

import tensorflow as tf
print (tf.__version__)
print ('Hello world')

EDIT:- I ran this code through an anaconda terminal(after activating environment) and got this new 'verbose' message {My environment is 'TF-gpu'}编辑:-我通过 anaconda 终端(激活环境后)运行此代码并得到这个新的“详细”消息 {我的环境是 'TF-gpu'}

Traceback (most recent call last):
  File "C:\Users\neelg\.conda\envs\TF-gpu\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
    return importlib.import_module(mname)
  File "C:\Users\neelg\.conda\envs\TF-gpu\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 985, in _gcd_import
  File "<frozen importlib._bootstrap>", line 968, in _find_and_load
  File "<frozen importlib._bootstrap>", line 957, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 577, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 938, in create_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
ImportError: DLL load failed: The specified module could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\neelg\.conda\envs\TF-gpu\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\neelg\.conda\envs\TF-gpu\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\neelg\.conda\envs\TF-gpu\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
    return importlib.import_module('_pywrap_tensorflow_internal')
  File "C:\Users\neelg\.conda\envs\TF-gpu\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '_pywrap_tensorflow_internal'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "test.py", line 1, in <module>
    import tensorflow as tf
  File "C:\Users\neelg\.conda\envs\TF-gpu\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
    from tensorflow.python import *
  File "C:\Users\neelg\.conda\envs\TF-gpu\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "C:\Users\neelg\.conda\envs\TF-gpu\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 52, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "C:\Users\neelg\.conda\envs\TF-gpu\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
    return importlib.import_module(mname)
  File "C:\Users\neelg\.conda\envs\TF-gpu\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 985, in _gcd_import
  File "<frozen importlib._bootstrap>", line 968, in _find_and_load
  File "<frozen importlib._bootstrap>", line 957, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 577, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 938, in create_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
ImportError: DLL load failed: The specified module could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\neelg\.conda\envs\TF-gpu\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\neelg\.conda\envs\TF-gpu\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\neelg\.conda\envs\TF-gpu\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
    return importlib.import_module('_pywrap_tensorflow_internal')
  File "C:\Users\neelg\.conda\envs\TF-gpu\lib\importlib\__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '_pywrap_tensorflow_internal'


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/install_sources#common_installation_problems

for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.

Result when running specific commands===>运行特定命令时的结果===>

conda list:--康达清单:-

    # packages in environment at C:\Users\neelg\.conda\envs\TF-gpu:
#
# Name                    Version                   Build  Channel
_tflow_select             2.1.0                       gpu
absl-py                   0.8.1                    pypi_0    pypi
astor                     0.8.0                    pypi_0    pypi
backports-weakref         1.0rc1                   pypi_0    pypi
blas                      1.0                         mkl
bleach                    1.5.0                    pypi_0    pypi
certifi                   2018.8.24                py35_1
cudatoolkit               9.0                           1
cudnn                     7.6.0                 cuda9.0_0
gast                      0.3.2                      py_0
grpcio                    1.24.3                   pypi_0    pypi
h5py                      2.10.0                   pypi_0    pypi
hdf5                      1.10.2               hac2f561_1
html5lib                  0.9999999                pypi_0    pypi
icc_rt                    2019.0.0             h0cc432a_1
intel-openmp              2019.4                      245
keras                     2.0.5                    pypi_0    pypi
keras-applications        1.0.4                    py35_1
keras-base                2.2.2                    py35_0
keras-preprocessing       1.0.2                    py35_1
libmklml                  2019.0.5                      0
libprotobuf               3.6.0                h1a1b453_0
markdown                  2.2.0                    pypi_0    pypi
mkl                       2018.0.3                      1
numpy                     1.17.3                   pypi_0    pypi
pip                       10.0.1                   py35_0
protobuf                  3.10.0                   pypi_0    pypi
python                    3.5.6                he025d50_0
pyyaml                    5.1.2                    pypi_0    pypi
scipy                     1.3.1                    pypi_0    pypi
setuptools                40.2.0                   py35_0
six                       1.12.0                   pypi_0    pypi
tensorboard               1.8.0                    pypi_0    pypi
tensorflow                1.8.0                    pypi_0    pypi
tensorflow-base           1.10.0          gpu_py35h6e53903_0
tensorflow-gpu            1.2.0                    pypi_0    pypi
termcolor                 1.1.0                    pypi_0    pypi
theano                    1.0.4                    pypi_0    pypi
vc                        14.1                 h0510ff6_4
vs2015_runtime            14.16.27012          hf0eaf9b_0
werkzeug                  0.16.0                     py_0
wheel                     0.31.1                   py35_0
wincertstore              0.2              py35hfebbdb8_0
yaml                      0.1.7                hc54c509_2
zlib                      1.2.11               h62dcd97_3

pip list-- pip列表--

    Package             Version
------------------- ---------
absl-py             0.8.1
astor               0.8.0
backports.weakref   1.0rc1
bleach              1.5.0
certifi             2018.8.24
gast                0.3.2
grpcio              1.24.3
h5py                2.10.0
html5lib            0.9999999
Keras               2.2.2
Keras-Applications  1.0.6
Keras-Preprocessing 1.0.5
Markdown            2.6.11
numpy               1.17.3
pip                 10.0.1
protobuf            3.10.0
PyYAML              5.1.2
scipy               1.3.1
setuptools          40.2.0
six                 1.12.0
tensorboard         1.10.0
tensorflow          1.10.0
tensorflow-gpu      1.2.0
termcolor           1.1.0
Theano              1.0.4
Werkzeug            0.16.0
wheel               0.31.1
wincertstore        0.2

Please follow the below steps to create conda environment and install tensorflow.请按照以下步骤创建 conda 环境并安装 tensorflow。

conda create -n env_tf -c intel python=3.5
source activate env_tf
pip install intel-tensorflow==<version>

This worked for me.Hope this helps这对我有用。希望这会有所帮助

The problem was solved by me(after a whole week).我解决了这个问题(整整一周后)。 The solution was to downgrade python from 3.5.6 to 3.5.4.解决方案是将 python 从 3.5.6 降级到 3.5.4。 Not clear why such a minor difference caused such problems: .) Hope it helps someone else too....不清楚为什么这么小的差异会导致这样的问题:.) 希望它也对其他人有所帮助....

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ModuleNotFoundError:没有名为“tensorflow”的模块? - ModuleNotFoundError: No module named 'tensorflow'? ModuleNotFoundError:anaconda 中没有名为“tensorflow”的模块 - ModuleNotFoundError: No module named 'tensorflow' in anaconda Anaconda:ModuleNotFoundError:没有名为“tensorflow”的模块 - Anaconda : ModuleNotFoundError: No module named 'tensorflow' ModuleNotFoundError:没有名为“nets”的模块(TensorFlow) - ModuleNotFoundError: No module named 'nets' (TensorFlow) ModuleNotFoundError:在 vscode 中没有名为“tensorflow”的模块 - ModuleNotFoundError: No module named 'tensorflow' in vscode Tensorflow&gt; ModuleNotFoundError:没有名为&#39;tensorflow.contrib&#39;的模块 - Tensorflow > ModuleNotFoundError: No module named 'tensorflow.contrib' ModuleNotFoundError:没有名为“tensorflow.contrib.tensorboard”的模块 - ModuleNotFoundError: No module named 'tensorflow.contrib.tensorboard' ModuleNotFoundError:没有名为“tensorflow.python.training”的模块 - ModuleNotFoundError: No module named 'tensorflow.python.training' ModuleNotFoundError:没有名为“tensorflow.compiler”的模块 - ModuleNotFoundError: No module named 'tensorflow.compiler' Python-TensorFlow-ModuleNotFoundError:没有名为x的模块 - Python - TensorFlow - ModuleNotFoundError: No module named x
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM