尝试运行import tensorflow as tf
,但失败。
我刚刚安装了tensorflow,但不允许导入。
这是错误
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
~\AppData\Local\Continuum\anaconda\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>()
57
---> 58 from tensorflow.python.pywrap_tensorflow_internal import *
59 from tensorflow.python.pywrap_tensorflow_internal import __version__
~\AppData\Local\Continuum\anaconda\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py in <module>()
27 return _mod
---> 28 _pywrap_tensorflow_internal = swig_import_helper()
29 del swig_import_helper
~\AppData\Local\Continuum\anaconda\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py in swig_import_helper()
23 try:
---> 24 _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
25 finally:
~\AppData\Local\Continuum\anaconda\lib\imp.py in load_module(name, file, filename, details)
242 else:
--> 243 return load_dynamic(name, filename, file)
244 elif type_ == PKG_DIRECTORY:
~\AppData\Local\Continuum\anaconda\lib\imp.py in load_dynamic(name, path, file)
342 name=name, loader=loader, origin=path)
--> 343 return _load(spec)
344
ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
<ipython-input-17-64156d691fe5> in <module>()
----> 1 import tensorflow as tf
~\AppData\Local\Continuum\anaconda\lib\site-packages\tensorflow\__init__.py in <module>()
22
23 # pylint: disable=g-bad-import-order
---> 24 from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
25
26 from tensorflow._api.v1 import app
~\AppData\Local\Continuum\anaconda\lib\site-packages\tensorflow\python\__init__.py in <module>()
47 import numpy as np
48
---> 49 from tensorflow.python import pywrap_tensorflow
50
51 # Protocol buffers
~\AppData\Local\Continuum\anaconda\lib\site-packages\tensorflow\python\pywrap_tensorflow.py in <module>()
72 for some common reasons and solutions. Include the entire stack trace
73 above this error message when asking for help.""" % traceback.format_exc()
---> 74 raise ImportError(msg)
75
76 # pylint: enable=wildcard-import,g-import-not-at-top,unused-import,line-too-long
ImportError: Traceback (most recent call last):
File "C:\Users\AMartinez147\AppData\Local\Continuum\anaconda\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\AMartinez147\AppData\Local\Continuum\anaconda\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\AMartinez147\AppData\Local\Continuum\anaconda\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
File "C:\Users\AMartinez147\AppData\Local\Continuum\anaconda\lib\imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "C:\Users\AMartinez147\AppData\Local\Continuum\anaconda\lib\imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: DLL load failed: The specified module could not be found.
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/errors
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
这是pip list
Package Version
---------------------------------- ----------
absl-py 0.7.1
alabaster 0.7.11
altair 2.2.2
anaconda-client 1.7.2
anaconda-navigator 1.9.6
anaconda-project 0.8.2
aniso8601 5.1.0
appdirs 1.4.3
asn1crypto 0.24.0
astor 0.7.1
astroid 2.0.4
astropy 3.0.4
atomicwrites 1.2.1
attrs 18.2.0
Automat 0.7.0
Babel 2.6.0
backcall 0.1.0
backports.shutil-get-terminal-size 1.0.0
beautifulsoup4 4.6.3
bitarray 0.8.3
bkcharts 0.2
blaze 0.11.3
bleach 2.1.4
bokeh 0.13.0
boto 2.49.0
Bottleneck 1.2.1
branca 0.3.0
category-encoders 1.3.0
certifi 2018.11.29
cffi 1.11.5
chardet 3.0.4
click 6.7
cloudpickle 0.5.5
clyent 1.2.2
colorama 0.3.9
colorlover 0.3.0
comtypes 1.1.7
conda 4.6.7
conda-build 3.15.1
constantly 15.1.0
contextlib2 0.5.5
cryptography 2.4.2
cufflinks 0.14.6
cycler 0.10.0
Cython 0.28.5
cytoolz 0.9.0.1
dash 0.29.0
dash-core-components 0.37.1
dash-html-components 0.13.2
dash-renderer 0.14.3
dask 0.19.1
datashape 0.5.4
decorator 4.3.0
defusedxml 0.5.0
distributed 1.23.1
docopt 0.6.2
docutils 0.14
entrypoints 0.2.3
et-xmlfile 1.0.1
fastcache 1.0.2
filelock 3.0.8
Flask 1.0.2
Flask-Compress 1.4.0
Flask-Cors 3.0.6
flask-restplus 0.12.1
folium 0.6.0
gast 0.2.2
geographiclib 1.49
geopy 1.17.0
gevent 1.3.6
glob2 0.6
greenlet 0.4.15
grpcio 1.20.1
h5py 2.8.0
heapdict 1.0.0
html5lib 1.0.1
hyperlink 18.0.0
idna 2.7
imageio 2.4.1
imagesize 1.1.0
imbalanced-learn 0.4.3
incremental 17.5.0
ipykernel 4.10.0
ipython 6.5.0
ipython-genutils 0.2.0
ipywidgets 7.4.1
isort 4.3.4
itsdangerous 0.24
jdcal 1.4
jedi 0.12.1
Jinja2 2.10
jsonschema 2.6.0
jupyter 1.0.0
jupyter-client 5.2.3
jupyter-console 5.2.0
jupyter-core 4.4.0
jupyterlab 0.34.9
jupyterlab-launcher 0.13.1
jupyterthemes 0.20.0
Keras-Applications 1.0.7
Keras-Preprocessing 1.0.9
keyring 13.2.1
kiwisolver 1.0.1
lazy-object-proxy 1.3.1
lesscpy 0.13.0
llvmlite 0.24.0
locket 0.2.0
lxml 4.2.5
Markdown 3.1
MarkupSafe 1.0
matplotlib 2.2.3
mccabe 0.6.1
memory-profiler 0.55.0
menuinst 1.4.14
mistune 0.8.3
mkl-fft 1.0.10
mkl-random 1.0.2
mock 2.0.0
more-itertools 4.3.0
mpmath 1.0.0
msgpack 0.5.6
multipledispatch 0.6.0
navigator-updater 0.2.1
nbconvert 5.4.0
nbformat 4.4.0
networkx 2.1
nltk 3.3
nose 1.3.7
notebook 5.6.0
num2words 0.5.9
numba 0.39.0
numexpr 2.6.8
numpy 1.15.4
numpydoc 0.8.0
odo 0.5.1
olefile 0.46
openpyxl 2.5.6
packaging 17.1
pandas 0.23.4
pandocfilters 1.4.2
parso 0.3.1
partd 0.3.8
path.py 11.1.0
pathlib2 2.3.2
patsy 0.5.0
pbr 5.2.0
pep8 1.7.1
pickleshare 0.7.4
Pillow 5.2.0
pip 19.1
pkginfo 1.4.2
plotly 3.3.0
pluggy 0.7.1
ply 3.11
prometheus-client 0.3.1
prompt-toolkit 1.0.15
protobuf 3.7.1
psutil 5.4.7
py 1.6.0
pyasn1 0.4.4
pyasn1-modules 0.2.2
pycodestyle 2.4.0
pycosat 0.6.3
pycparser 2.18
pycrypto 2.6.1
pycurl 7.43.0.2
pyflakes 2.0.0
Pygments 2.2.0
pylint 2.1.1
pyodbc 4.0.24
pyOpenSSL 18.0.0
pyparsing 2.2.0
PySocks 1.6.8
pytest 3.8.0
pytest-arraydiff 0.2
pytest-astropy 0.4.0
pytest-doctestplus 0.1.3
pytest-openfiles 0.3.0
pytest-remotedata 0.3.0
python-dateutil 2.7.3
pytz 2018.5
PyWavelets 1.0.0
pywin32 223
pywinpty 0.5.4
PyYAML 3.13
pyzmq 17.1.2
QtAwesome 0.4.4
qtconsole 4.4.1
QtPy 1.5.0
relativetimebuilder 0.2.0
requests 2.19.1
retrying 1.3.3
rope 0.11.0
ruamel-yaml 0.15.46
scikit-image 0.14.0
scikit-learn 0.20.3
scipy 1.1.0
seaborn 0.9.0
Send2Trash 1.5.0
service-identity 17.0.0
setuptools 40.2.0
simplegeneric 0.8.1
singledispatch 3.4.0.3
six 1.11.0
snowballstemmer 1.2.1
sortedcollections 1.0.1
sortedcontainers 2.0.5
Sphinx 1.7.9
sphinxcontrib-websupport 1.1.0
spyder 3.3.1
spyder-kernels 0.2.6
SQLAlchemy 1.2.11
statsmodels 0.9.0
sympy 1.1.1
tables 3.4.4
tblib 1.3.2
tensorboard 1.13.1
tensorflow 1.13.1
tensorflow-estimator 1.13.0
tensorflow-gpu 1.13.1
termcolor 1.1.0
terminado 0.8.1
testpath 0.3.1
textdistance 4.1.2
toolz 0.9.0
tornado 5.1
tqdm 4.26.0
traitlets 4.3.2
Twisted 18.7.0
unicodecsv 0.14.1
urllib3 1.23
vincent 0.4.4
wcwidth 0.1.7
webencodings 0.5.1
Werkzeug 0.14.1
wheel 0.31.1
widgetsnbextension 3.4.1
win-inet-pton 1.0.1
win-unicode-console 0.5
wincertstore 0.2
wrapt 1.10.11
xgboost 0.82
xlrd 1.1.0
XlsxWriter 1.1.0
xlwings 0.11.8
xlwt 1.3.0
zict 0.1.3
zope.interface 4.5.0
答案 0 :(得分:0)
您可以使用本文建议的诊断步骤: https://github.com/tensorflow/tensorflow/issues/11065
最简单的方法如下:
经过大量搜索并尝试安装并重新安装Python之后,我发现该解决方案非常简单 对于Windows使用以下内容
python -m pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.0-py3-none-any.whl
您应该根据您的操作系统和python版本从此链接更新网址: