I am trying a to import tensorflow in jupyter but I get this error--
ImportError Traceback (most recent call
last)
C:\Users\Dell\Anaconda3\lib\site-packages\tensorflow\python
\pywrap_tensorflow_internal.py in swig_import_helper()
17 try:
---> 18 return importlib.import_module(mname)
19 except ImportError:
C:\Users\Dell\Anaconda3\lib\importlib\__init__.py in import_module(name,
package)
125 level += 1
--> 126 return _bootstrap._gcd_import(name[level:], package, level)
127
C:\Users\Dell\Anaconda3\lib\importlib\_bootstrap.py in _gcd_import(name,
package, level)
C:\Users\Dell\Anaconda3\lib\importlib\_bootstrap.py in
_find_and_load(name, import_)
C:\Users\Dell\Anaconda3\lib\importlib\_bootstrap.py in
_find_and_load_unlocked(name, import_)
C:\Users\Dell\Anaconda3\lib\importlib\_bootstrap.py in
_load_unlocked(spec)
C:\Users\Dell\Anaconda3\lib\importlib\_bootstrap.py in
module_from_spec(spec)
C:\Users\Dell\Anaconda3\lib\importlib\_bootstrap_external.py in
create_module(self, spec)
C:\Users\Dell\Anaconda3\lib\importlib\_bootstrap.py in
_call_with_frames_removed(f, *args, **kwds)
ImportError: DLL load failed: The specified module could not be found.
During handling of the above exception, another exception occurred:
ModuleNotFoundError Traceback (most recent call
last)
C:\Users\Dell\Anaconda3\lib\site-packages\tensorflow\python
\pywrap_tensorflow.py in <module>()
40 sys.setdlopenflags(_default_dlopen_flags | ctypes.RTLD_GLOBAL)
---> 41 from tensorflow.python.pywrap_tensorflow_internal import *
42 from tensorflow.python.pywrap_tensorflow_internal import
__version__
C:\Users\Dell\Anaconda3\lib\site-packages\tensorflow\python
\pywrap_tensorflow_internal.py in <module>()
20 return
importlib.import_module('_pywrap_tensorflow_internal')
---> 21 _pywrap_tensorflow_internal = swig_import_helper()
22 del swig_import_helper
C:\Users\Dell\Anaconda3\lib\site-packages\tensorflow\python
\pywrap_tensorflow_internal.py in swig_import_helper()
19 except ImportError:
importlib.import_module('_pywrap_tensorflow_internal')
21 _pywrap_tensorflow_internal = swig_import_helper()
C:\Users\Dell\Anaconda3\lib\importlib\__init__.py in import_module(name,
package)
125 level += 1
127
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call
last)
<ipython-input-1-41389fad42b5> in <module>()
----> 1 import tensorflow as tf
C:\Users\Dell\Anaconda3\lib\site-packages\tensorflow\__init__.py in
<module>()
22
23 # pylint: disable=wildcard-import
---> 24 from tensorflow.python import *
25 # pylint: enable=wildcard-import
26
C:\Users\Dell\Anaconda3\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
C:\Users\Dell\Anaconda3\lib\site-packages\tensorflow\python
\pywrap_tensorflow.py in <module>()
50 for some common reasons and solutions. Include the entire stack
trace
51 above this error message when asking for help.""" %
traceback.format_exc()
---> 52 raise ImportError(msg)
53
54 # pylint: enable=wildcard-import,g-import-not-at-top,unused-
import,line-too-long
ImportError: Traceback (most recent call last):
File "C:\Users\Dell\Anaconda3\lib\site-packages\tensorflow\python
\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:\Users\Dell\Anaconda3\lib\importlib\__init__.py", line 126, in
import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 978, in _gcd_import
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in
_find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 648, in _load_unlocked
File "<frozen importlib._bootstrap>", line 560, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 922, in create_module
File "<frozen importlib._bootstrap>", line 205, 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\Dell\Anaconda3\lib\site-packages\tensorflow\python
\pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\Dell\Anaconda3\lib\site-packages\tensorflow\python
\pywrap_tensorflow_internal.py", line 21, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\Dell\Anaconda3\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\Dell\Anaconda3\lib\importlib\__init__.py", line 126, in
import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'
Failed to load the native TensorFlow runtime.
I try to install jupyter notebook within virtual tensorflow environment using pip without uninstalling the previous one.But error still exists.
I came to that jupyter should be installed under virtual environment.
I also cannot uninstall the previously installed jupyter.
Thanks in advance
I cannot figure out your problem, but I can suggest you a workaround. First install docker community edition, if you don't already have it. Just follow the instruction at:
https://docs.docker.com/install/
Then, once installed, open Kitematic, it will appear right-clicking the docker symbol. Once it starts, click on "new" and in the search box type "tensorflow-notebook" and then click "create". It will take some moment to fire up but it is a fantastic way of experiencing TF on Jupyter. Be careful though that by definition a Docker is stateless! So take care to configure under Settings/Volumes associated with the TF Docker in Kitematic, a Local Folder where to save all the stuff you want to save.
Related
I am trying to install tensorflow 1.8 cpu version with python 3.6 on my windows 64 bit os. Anyone konw that whether the tensorflow 1.8 support python 3.6 in windows 64 bit system? The table here TF install guide didn't mention it. I had met the same problems bofore and it seems that the tensorflow version is too new for python 3.x to support on windows.
here are the issues:
Traceback (most recent call last):
File "D:\python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 14, in swig_import_helper
return importlib.import_module(mname)
File "D:\python36\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 658, in _load_unlocked
File "<frozen importlib._bootstrap>", line 571, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 922, in create_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: DLL load failed: 动态链接库(DLL)初始化例程失败。
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\python36\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "D:\python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 17, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "D:\python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 16, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow_internal')
File "D:\python36\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "D:\python36\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "D:\python36\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "D:\python36\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "D:\python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 14, in swig_import_helper
return importlib.import_module(mname)
File "D:\python36\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 658, in _load_unlocked
File "<frozen importlib._bootstrap>", line 571, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 922, in create_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: DLL load failed: 动态链接库(DLL)初始化例程失败。
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\python36\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "D:\python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 17, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "D:\python36\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 16, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow_internal')
File "D:\python36\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: 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.
Tragedy. It turns out that my computer with a Intel(R) Celeron(R) cpu N2940 and it doesn't support AVX instructions. TF version >= 1.6 will need AVX. That's it.
I am attempting to install tensorflow 1.8 to 1.10.1. Unfortunately, I installed it with both pip and conda, and while it worked when I tried to upgrade to tensorflow 1.10.1 I get the below error message. I have attempted to remove it with both pip and conda as well as create a new conda environment and install it fresh in conda. With no other versions of tensorflow installed (for any other conda env as well) I ran:
conda create -n testing python=3.6.5 scipy numpy jupyter scikit-learn matplotlib seaborn nltk tensorflow
Then when I import tensorflow I get the same error message:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
/anaconda3/envs/testing/lib/python3.6/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__
/anaconda3/envs/testing/lib/python3.6/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
/anaconda3/envs/testing/lib/python3.6/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:
/anaconda3/envs/testing/lib/python3.6/imp.py in load_module(name, file, filename, details)
242 else:
--> 243 return load_dynamic(name, filename, file)
244 elif type_ == PKG_DIRECTORY:
/anaconda3/envs/testing/lib/python3.6/imp.py in load_dynamic(name, path, file)
342 name=name, loader=loader, origin=path)
--> 343 return _load(spec)
344
ImportError: dlopen(/anaconda3/envs/testing/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so, 6): Symbol not found: __ZN10tensorflow10DeviceBase16eigen_cpu_deviceEv
Referenced from: /anaconda3/envs/testing/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so
Expected in: /Users/avanders/tensorflow_libs/lib/libtensorflow_framework.so
in /anaconda3/envs/testing/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so
During handling of the above exception, another exception occurred:
ImportError Traceback (most recent call last)
<ipython-input-2-64156d691fe5> in <module>()
----> 1 import tensorflow as tf
/anaconda3/envs/testing/lib/python3.6/site-packages/tensorflow/__init__.py in <module>()
20
21 # pylint: disable=g-bad-import-order
---> 22 from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
23
24 try:
/anaconda3/envs/testing/lib/python3.6/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
/anaconda3/envs/testing/lib/python3.6/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 "/anaconda3/envs/testing/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/anaconda3/envs/testing/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/anaconda3/envs/testing/lib/python3.6/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 "/anaconda3/envs/testing/lib/python3.6/imp.py", line 243, in load_module
return load_dynamic(name, filename, file)
File "/anaconda3/envs/testing/lib/python3.6/imp.py", line 343, in load_dynamic
return _load(spec)
ImportError: dlopen(/anaconda3/envs/testing/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so, 6): Symbol not found: __ZN10tensorflow10DeviceBase16eigen_cpu_deviceEv
Referenced from: /anaconda3/envs/testing/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so
Expected in: /Users/avanders/tensorflow_libs/lib/libtensorflow_framework.so
in /anaconda3/envs/testing/lib/python3.6/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so
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.
So it turns out the problem was a conflict in versions with the go wrappers I had installed for the tensorflow library. Once I updated those wrappers to the same version a conda install worked.
I installed tensorflow 1.8.0 using the command
pip3 install --upgrade tensorflow
It was installed properly, but when I typed the command
`import tensorflow as tf`
the following errors came:
Traceback (most recent call last):
File "C:\Users\USER\AppData\Local\Programs\Python\Python36-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 14, in swig_import_helper
return importlib.import_module(mname)
File "C:\Users\USER\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 658, in _load_unlocked
File "<frozen importlib._bootstrap>", line 571, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 922, in create_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: DLL load failed: %1 is not a valid Win32 application.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\USER\AppData\Local\Programs\Python\Python36-32\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\USER\AppData\Local\Programs\Python\Python36-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 17, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\USER\AppData\Local\Programs\Python\Python36-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 16, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow_internal')
File "C:\Users\USER\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<pyshell#16>", line 1, in <module>
import tensorflow as tf
File "C:\Users\USER\AppData\Local\Programs\Python\Python36-32\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "C:\Users\USER\AppData\Local\Programs\Python\Python36-32\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\USER\AppData\Local\Programs\Python\Python36-32\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\USER\AppData\Local\Programs\Python\Python36-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 14, in swig_import_helper
return importlib.import_module(mname)
File "C:\Users\USER\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 658, in _load_unlocked
File "<frozen importlib._bootstrap>", line 571, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 922, in create_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: DLL load failed: %1 is not a valid Win32 application.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\USER\AppData\Local\Programs\Python\Python36-32\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\USER\AppData\Local\Programs\Python\Python36-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 17, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\USER\AppData\Local\Programs\Python\Python36-32\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 16, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow_internal')
File "C:\Users\USER\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_pywrap_tensorflow_internal'
Failed to load the native TensorFlow runtime.
I searched a lot. I even installed tensorflow once more, but in vain.
I could not find any solution in internet. Can someone help me? Thank you in advance. :)
The TensorFlow Windows packages will only work with 64-Bit Python. It appears that your Python installation is 32-Bit. Install a 64-Bit Python version and you should be able to install TensorFlow without a problem.
I had exactly the same problem in my Windows 7 64 bits. In my case, TensorFlow 2.1 for Python 3.7.6 has installed OK. When I run a small demo gives this error. So I've installed the Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017 and 2019, X64 version and everything works as charm.
I have installed python 3.5.2, and installed TensorFlow throght the command
pip3 install tensorflow --upgrade
After the installation finished, I try to import the TensorFlow, but failed. The error report is as follow. How to fix this problem?
import tensorflow Traceback (most recent call last): File "C:\Python\Python352\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",
line 18, in swig_import_helper
return importlib.import_module(mname) File "C:\Python\Python352\lib\importlib__init__.py", line 126, in
import_module
return _bootstrap._gcd_import(name[level:], package, level) File "", line 986, in _gcd_import File
"", line 969, in _find_and_load File
"", line 958, in _find_and_load_unlocked
File "", line 666, in _load_unlocked
File "", line 577, in module_from_spec
File "", line 906, in
create_module File "", line 222, in
_call_with_frames_removed ImportError: DLL load failed: 找不到指定的模块。(Could not find the moudle)
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"C:\Python\Python352\lib\site-packages\tensorflow\python\pywrap_tensorflow.py",
line 41, in
from tensorflow.python.pywrap_tensorflow_internal import * File "C:\Python\Python352\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",
line 21, in
_pywrap_tensorflow_internal = swig_import_helper() File "C:\Python\Python352\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",
line 20, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow_internal') File "C:\Python\Python352\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 "", line 1, in
File
"C:\Python\Python352\lib\site-packages\tensorflow__init__.py", line
24, in
from tensorflow.python import * File "C:\Python\Python352\lib\site-packages\tensorflow\python__init__.py",
line 51, in
from tensorflow.python import pywrap_tensorflow File "C:\Python\Python352\lib\site-packages\tensorflow\python\pywrap_tensorflow.py",
line 52, in
raise ImportError(msg) ImportError: Traceback (most recent call last): File
"C:\Python\Python352\lib\site-packages\tensorflow\python\pywrap_tensorflo
w_internal.py", line 18, in swig_import_helper
return importlib.import_module(mname) File "C:\Python\Python352\lib\importlib__init__.py", line 126, in
import_module
return _bootstrap._gcd_import(name[level:], package, level) File "", line 986, in _gcd_import File
"", line 969, in _find_and_load File
"", line 958, in _find_and_load_unlocked
File "", line 666, in _load_unlocked
File "", line 577, in module_from_spec
File "", line 906, in
create_module File "", line 222, in
_call_with_frames_removed ImportError: DLL load failed: 找不到指定的模块。(could not find the moudle)
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"C:\Python\Python352\lib\site-packages\tensorflow\python\pywrap_tensorflo
w.py", line 41, in
from tensorflow.python.pywrap_tensorflow_internal import * File "C:\Python\Python352\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",
line 21, in
_pywrap_tensorflow_internal = swig_import_helper() File "C:\Python\Python352\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",
line 20, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow_internal') File "C:\Python\Python352\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.
I am trying to run MNIST prediction using tensorflow.
Files:
https://github.com/niektemme/tensorflow-mnist-predict/
CMD Line Code:
python predict_1.py ‘number1.png’
I can execute the program in PyCharm without an error, but when I try executing the script through the command line, I get an error.
Traceback (most recent call last):
File "predict_1.py", line 29, in <module>
import tensorflow as tf
ModuleNotFoundError: No module named 'tensorflow'
I checked pip3 list to confirm installed:
tensorflow (1.0.1)
Update1:
I ran this test in both environments:
import os
print(os.file)
PyCharm:
C:\Users\\AppData\Local\Programs\Python\Python35\python.exe
C:/Users//AppData/Local/Programs/Python/Python35/Scripts/tensorflow-mnist-predict-master/tensorflow-mnist-predict-master/test.py
C:\Users\\AppData\Local\Programs\Python\Python35\lib\os.py
CMD Line:
C:\ProgramData\Anaconda3\lib\os.py
Update2:
I removed Anaconda3 from the environment variables, and
CMD Line now reads:
C:\Users\\AppData\Local\Programs\Python\Python35\lib\os.py
This is the error I get trying to run tensorflow through the CMD line:
Traceback (most recent call last):
File "C:\Users\\AppData\Local\Programs\Python\Python35\Lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:\Users\\AppData\Local\Programs\Python\Python35\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, 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 906, 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\\AppData\Local\Programs\Python\Python35\Lib\site-packages\tensorflow\python\__init__.py", line 54, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\\AppData\Local\Programs\Python\Python35\Lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 21, in <module>
_pywrap_tensorflow = swig_import_helper()
File "C:\Users\\AppData\Local\Programs\Python\Python35\Lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 20, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow')
File "C:\Users\\AppData\Local\Programs\Python\Python35\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '_pywrap_tensorflow'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "predict_1.py", line 29, in <module>
import tensorflow as tf
File "C:\Users\\AppData\Local\Programs\Python\Python35\Lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import *
File "C:\Users\\AppData\Local\Programs\Python\Python35\Lib\site-packages\tensorflow\python\__init__.py", line 60, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\\AppData\Local\Programs\Python\Python35\Lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:\Users\\AppData\Local\Programs\Python\Python35\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, 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 906, 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\\AppData\Local\Programs\Python\Python35\Lib\site-packages\tensorflow\python\__init__.py", line 54, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\\AppData\Local\Programs\Python\Python35\Lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 21, in <module>
_pywrap_tensorflow = swig_import_helper()
File "C:\Users\\AppData\Local\Programs\Python\Python35\Lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 20, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow')
File "C:\Users\\AppData\Local\Programs\Python\Python35\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '_pywrap_tensorflow'
Error importing tensorflow. Unless you are using bazel,
you should not try to import tensorflow from its source directory;
please exit the tensorflow source tree, and relaunch your python interpreter from there.
Judging from your edits, you have two separate python installations, one in Users\AppData and one in ProgramData\Anaconda3. Your PyCharm uses the first one, but when you just run python command from CLI you get the second one. There are two ways to resolve this, you can adjust your PATH variable to point to the first installation, so python from CLI is the same as your PyCharm or you can install TensorFlow on the second install (this might lead to further confusion if there are other libraries your code depends on). Here is a link with directions on editing your PATH variable (https://www.howtogeek.com/118594/how-to-edit-your-system-path-for-easy-command-line-access/). You want to make sure that C:\Users\\AppData\Local\Programs\Python\Python35 is in there and C:\ProgramData\Anaconda3 is not.