I get the following errors during import of TensorFlow using Python 3.5.2.
Can anyone help with this?
>>> import tensorflow as tf
Traceback (most recent call last):
File "C:\Users\zberenyi\AppData\Local\Programs\Python\Python35\lib\site-packag
es\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_hel
per
return importlib.import_module(mname)
File "C:\Users\zberenyi\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: A megadott eljárás nem található.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\zberenyi\AppData\Local\Programs\Python\Python35\lib\site-packag
es\tensorflow\python\pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\zberenyi\AppData\Local\Programs\Python\Python35\lib\site-packag
es\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\zberenyi\AppData\Local\Programs\Python\Python35\lib\site-packag
es\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_hel
per
return importlib.import_module('_pywrap_tensorflow_internal')
File "C:\Users\zberenyi\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_internal'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\zberenyi\AppData\Local\Programs\Python\Python35\lib\site-packag
es\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import *
File "C:\Users\zberenyi\AppData\Local\Programs\Python\Python35\lib\site-packag
es\tensorflow\python\__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\zberenyi\AppData\Local\Programs\Python\Python35\lib\site-packag
es\tensorflow\python\pywrap_tensorflow.py", line 52, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\zberenyi\AppData\Local\Programs\Python\Python35\lib\site-packag
es\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_hel
per
return importlib.import_module(mname)
File "C:\Users\zberenyi\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: A megadott eljárás nem található.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\zberenyi\AppData\Local\Programs\Python\Python35\lib\site-packag
es\tensorflow\python\pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Users\zberenyi\AppData\Local\Programs\Python\Python35\lib\site-packag
es\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Users\zberenyi\AppData\Local\Programs\Python\Python35\lib\site-packag
es\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_hel
per
return importlib.import_module('_pywrap_tensorflow_internal')
File "C:\Users\zberenyi\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_internal'
Failed to load the native TensorFlow runtime.
See https://www.tensorflow.org/install/install_sources#common_installation_probl
ems
................
I have vc_redist.x64.exe and vs_community__35732741.1502806003.exe installed.
I try to use the basic CPU form of TensorFlow. This was installed using:
pip3 install --upgrade tensorflow
Related
Had a setup on ubuntu with python3.9 and pandas working perfectly. Things were perfect until.. pandas just stopped working. I removed all python versions and reinstalled python3.9 from scratch. Now I am getting this:
userA#serverB:/somefolder$ python3.9 -m pip install --no-cache-dir pandas
Collecting pandas
Downloading https://files.pythonhosted.org/packages/f4/00/2de395c769335956b8650f990ef2a15e860be83b544c408ff95713446329/pandas-1.4.3.tar.gz (4.9MB)
100% |████████████████████████████████| 4.9MB 79.6MB/s
Exception:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 342, in run
requirement_set.prepare_files(finder)
File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 376, in prepare_files
discovered_reqs.extend(self._prepare_file(
File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 634, in _prepare_file
abstract_dist.prep_for_dist()
File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 129, in prep_for_dist
self.req_to_install.run_egg_info()
File "/usr/lib/python3/dist-packages/pip/req/req_install.py", line 412, in run_egg_info
self.setup_py, self.name,
File "/usr/lib/python3/dist-packages/pip/req/req_install.py", line 387, in setup_py
import setuptools # noqa
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
File "<frozen importlib._bootstrap>", line 627, in _load_backward_compatible
File "<frozen zipimport>", line 259, in load_module
File "/usr/share/python-wheels/setuptools-39.0.1-py2.py3-none-any.whl/setuptools/__init__.py", line 14, in <module>
from setuptools.dist import Distribution, Feature
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
File "<frozen importlib._bootstrap>", line 627, in _load_backward_compatible
File "<frozen zipimport>", line 259, in load_module
File "/usr/share/python-wheels/setuptools-39.0.1-py2.py3-none-any.whl/setuptools/dist.py", line 24, in <module>
from setuptools.depends import Require
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
File "<frozen importlib._bootstrap>", line 627, in _load_backward_compatible
File "<frozen zipimport>", line 259, in load_module
File "/usr/share/python-wheels/setuptools-39.0.1-py2.py3-none-any.whl/setuptools/depends.py", line 7, in <module>
from .py33compat import Bytecode
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
File "<frozen importlib._bootstrap>", line 627, in _load_backward_compatible
File "<frozen zipimport>", line 259, in load_module
File "/usr/share/python-wheels/setuptools-39.0.1-py2.py3-none-any.whl/setuptools/py33compat.py", line 54, in <module>
unescape = getattr(html, 'unescape', html_parser.HTMLParser().unescape)
AttributeError: 'HTMLParser' object has no attribute 'unescape'
This is some further detail on the pandas or numpy errors
python3.9
Python 3.9.13 (main, May 23 2022, 22:02:02)
[GCC 7.5.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas as pd
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3/dist-packages/pandas/__init__.py", line 18, in <module>
raise ImportError(
ImportError: Missing required dependencies ['numpy']
>>> import numpy as np
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/numpy/core/__init__.py", line 16, in <module>
from . import multiarray
ImportError: cannot import name 'multiarray' from partially initialized module 'numpy.core' (most likely due to a circular import) (/usr/lib/python3/dist-packages/numpy/core/__init__.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3/dist-packages/numpy/__init__.py", line 142, in <module>
from . import add_newdocs
File "/usr/lib/python3/dist-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/usr/lib/python3/dist-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/usr/lib/python3/dist-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/usr/lib/python3/dist-packages/numpy/core/__init__.py", line 26, in <module>
raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control). Otherwise reinstall numpy.
Original error was: cannot import name 'multiarray' from partially initialized module 'numpy.core' (most likely due to a circular import) (/usr/lib/python3/dist-packages/numpy/core/__init__.py)
>>>
No luck with other solutions online such as upgrading the pip3 or no cache. any thoughts?
when i opened jupternotebook in anaconda3, it showed that:
File "C:\ProgramData\Anaconda3\cwp.py", line 9, in <module>
from menuinst.knownfolders import FOLDERID, get_folder_path, PathNotFoundException
File "C:\ProgramData\Anaconda3\lib\site-packages\menuinst\__init__.py", line 23, in <module>
from .win32 import Menu, ShortCut
File "C:\ProgramData\Anaconda3\lib\site-packages\menuinst\win32.py", line 11, in <module>
import pywintypes
File "C:\ProgramData\Anaconda3\lib\site-packages\win32\lib\pywintypes.py", line 2, in <module>
import imp, sys, os
File "C:\ProgramData\Anaconda3\lib\imp.py", line 23, in <module>
from importlib import util
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 724, in exec_module
File "<frozen importlib._bootstrap_external>", line 857, in get_code
File "<frozen importlib._bootstrap_external>", line 525, in _compile_bytecode
ValueError: bad marshal data (unknown type code)
then i guessed it may be importlib's error but when i wanted to check the version of this package, i found i can't use the command below
PS C:\Users\Jayus> python -m pip list
Could not import runpy module
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\runpy.py", line 15, in <module>
import importlib.util
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 724, in exec_module
File "<frozen importlib._bootstrap_external>", line 857, in get_code
File "<frozen importlib._bootstrap_external>", line 525, in _compile_bytecode
ValueError: bad marshal data (unknown type code)
PS C:\Users\Jayus> pip list
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\Scripts\pip-script.py", line 6, in <module>
from pip._internal.cli.main import main
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_internal\cli\main.py", line 10, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_internal\cli\autocompletion.py", line 9, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_internal\cli\main_parser.py", line 7, in <module>
from pip._internal.cli import cmdoptions
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_internal\cli\cmdoptions.py", line 19, in <module>
from distutils.util import strtobool
File "C:\ProgramData\Anaconda3\lib\distutils\util.py", line 9, in <module>
import importlib.util
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 724, in exec_module
File "<frozen importlib._bootstrap_external>", line 857, in get_code
File "<frozen importlib._bootstrap_external>", line 525, in _compile_bytecode
ValueError: bad marshal data (unknown type code)
it clearly is the importlib's error but how can i fix it? I have tried install it in anaconda3 and the pycharm, but i can not even open it, when i use the command below, error again.
PS C:\Users\Jayus> conda activate base
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\_vendor\auxlib\_vendor\five.py", line 47, in <module>
reload = reload # noqa
NameError: name 'reload' is not defined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\Scripts\conda-script.py", line 12, in <module>
sys.exit(main())
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\cli\main.py", line 151, in main
from ..exceptions import conda_exception_handler
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\exceptions.py", line 19, in <module>
from ._vendor.auxlib.entity import EntityEncoder
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\_vendor\auxlib\entity.py", line 253, in <module>
from .collection import AttrDict, frozendict, make_immutable
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\_vendor\auxlib\collection.py", line 10, in <module>
from .compat import isiterable, iteritems, odict, text_type
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\_vendor\auxlib\compat.py", line 9, in <module>
from ._vendor.five import WhateverIO as StringIO, with_metaclass
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\_vendor\auxlib\_vendor\five.py", line 49, in <module>
from imp import reload # noqa
File "C:\ProgramData\Anaconda3\lib\imp.py", line 23, in <module>
from importlib import util
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 724, in exec_module
File "<frozen importlib._bootstrap_external>", line 857, in get_code
File "<frozen importlib._bootstrap_external>", line 525, in _compile_bytecode
ValueError: bad marshal data (unknown type code)
base is my env name, and it is the default env
by the way, i can not open anaconda3 powershell prompt and the navigator, that is the result.
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\_vendor\auxlib\_vendor\five.py", line 47, in <module>
reload = reload # noqa
NameError: name 'reload' is not defined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\cli\main.py", line 139, in main
from ..activate import main as activator_main
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\activate.py", line 20, in <module>
from ._vendor.auxlib.compat import Utf8NamedTemporaryFile
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\_vendor\auxlib\compat.py", line 9, in <module>
from ._vendor.five import WhateverIO as StringIO, with_metaclass
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\_vendor\auxlib\_vendor\five.py", line 49, in <module>
from imp import reload # noqa
File "C:\ProgramData\Anaconda3\lib\imp.py", line 23, in <module>
from importlib import util
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 724, in exec_module
File "<frozen importlib._bootstrap_external>", line 857, in get_code
File "<frozen importlib._bootstrap_external>", line 525, in _compile_bytecode
ValueError: bad marshal data (unknown type code)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\_vendor\auxlib\_vendor\five.py", line 47, in <module>
reload = reload # noqa
NameError: name 'reload' is not defined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\Scripts\conda-script.py", line 12, in <module>
sys.exit(main())
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\cli\main.py", line 147, in main
init_loggers()
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\cli\main.py", line 56, in init_loggers
from ..gateways.logging import initialize_logging, set_verbosity
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\gateways\logging.py", line 14, in <module>
from ..common.io import attach_stderr_handler
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\common\io.py", line 31, in <module>
from .._vendor.auxlib.logz import NullHandler
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\_vendor\auxlib\logz.py", line 9, in <module>
from .compat import text_type
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\_vendor\auxlib\compat.py", line 9, in <module>
from ._vendor.five import WhateverIO as StringIO, with_metaclass
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\_vendor\auxlib\_vendor\five.py", line 49, in <module>
from imp import reload # noqa
File "C:\ProgramData\Anaconda3\lib\imp.py", line 23, in <module>
from importlib import util
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 724, in exec_module
File "<frozen importlib._bootstrap_external>", line 857, in get_code
File "<frozen importlib._bootstrap_external>", line 525, in _compile_bytecode
ValueError: bad marshal data (unknown type code)
Invoke-Expression : 无法将参数绑定到参数“Command”,因为该参数为空字符串。
所在位置 C:\ProgramData\Anaconda3\shell\condabin\Conda.psm1:101 字符: 36
+ Invoke-Expression -Command $activateCommand;
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Invoke-Expression],ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Microsoft.PowerShell.Commands.Invo
keExpressionCommand
i can still use the python command,but that's it,that's all i can use maybe. thank you for all if you can help me.
I solved this, maybe not solve, i just reinstalled it....
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 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 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.