I receive the following error when importing tensorflow
(base) PS C:\Users\Rostyslav\GIt\GNN-GCP> python run_model.py --train --save
Traceback (most recent call last):
File "run_model.py", line 6, in <module>
import tensorflow as tf
File "C:\Users\Rostyslav\anaconda3\lib\site-packages\tensorflow\__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "C:\Users\Rostyslav\anaconda3\lib\site-packages\tensorflow\python\__init__.py", line 40, in <module>
from tensorflow.python.eager import context
File "C:\Users\Rostyslav\anaconda3\lib\site-packages\tensorflow\python\eager\context.py", line 35, in <module>
from tensorflow.python import pywrap_tfe
File "C:\Users\Rostyslav\anaconda3\lib\site-packages\tensorflow\python\pywrap_tfe.py", line 28, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\Rostyslav\anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 28, in <module>
self_check.preload_check()
File "C:\Users\Rostyslav\anaconda3\lib\site-packages\tensorflow\python\platform\self_check.py", line 54, in preload_check
raise ImportError(
ImportError: Could not find the DLL(s) 'msvcp140.dll or msvcp140_1.dll'. TensorFlow requires that these DLLs be installed in a directory that is named in your %PATH% environment variable. You may install these DLLs by downloading "Microsoft C++ Redistributable for Visual Studio 2015, 2017 and 2019" for your platform from this URL: https://support.microsoft.com/help/2977003/the-latest-supported-visual-c-downloads
even when I have both msvcp140.dll
and msvcp140_1.dll
installed and they are both placed in the directory specified by %PATH% environment variable
C:\Users\Rostyslav>where msvcp140.dll
C:\Program Files\Java\jdk-16\bin\msvcp140.dll
C:\Windows\System32\msvcp140.dll
C:\Users\Rostyslav\AppData\Local\Programs\Python\Python39\msvcp140.dll <-- HERE
C:\Users\Rostyslav\AppData\Local\Programs\MiKTeX\miktex\bin\x64\msvcp140.dll
My path environmental variable looks like this:
After searching, I found that the reason can be in incompatibility between protobuf
, tensorflow
, and python
. I have tried many different combinations of versions, but all of them lead to the same error.
The current versions are as follows:
tensorflow 2.5.0
python 3.8.10
protobuf 3.17.3
If you need any additional information, please let me know, and I will share. Any help is appreciated because I tackle this problem the whole day. Thank you!
Update:
After I modify self_check.py
to show more detailed information about the error, this is what I get
Traceback (most recent call last):
File "C:\Users\Rostyslav\anaconda3\lib\site-packages\tensorflow\python\platform\self_check.py", line 50, in preload_check
ctypes.WinDLL(dll_name)
File "C:\Users\Rostyslav\anaconda3\lib\ctypes\__init__.py", line 381, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 87] The parameter is incorrect
Traceback (most recent call last):
File "C:\Users\Rostyslav\anaconda3\lib\site-packages\tensorflow\python\platform\self_check.py", line 50, in preload_check
ctypes.WinDLL(dll_name)
File "C:\Users\Rostyslav\anaconda3\lib\ctypes\__init__.py", line 381, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 87] The parameter is incorrect
Traceback (most recent call last):
File "run_model.py", line 6, in <module>
import tensorflow as tf
File "C:\Users\Rostyslav\anaconda3\lib\site-packages\tensorflow\__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "C:\Users\Rostyslav\anaconda3\lib\site-packages\tensorflow\python\__init__.py", line 40, in <module>
from tensorflow.python.eager import context
File "C:\Users\Rostyslav\anaconda3\lib\site-packages\tensorflow\python\eager\context.py", line 35, in <module>
from tensorflow.python import pywrap_tfe
File "C:\Users\Rostyslav\anaconda3\lib\site-packages\tensorflow\python\pywrap_tfe.py", line 28, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\Rostyslav\anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 28, in <module>
self_check.preload_check()
File "C:\Users\Rostyslav\anaconda3\lib\site-packages\tensorflow\python\platform\self_check.py", line 55, in preload_check
raise ImportError(
ImportError: Could not find the DLL(s) 'msvcp140.dll or msvcp140_1.dll'. TensorFlow requires that these DLLs be installed in a directory that is named in your %PATH% environment variable. You may install these DLLs by downloading "Microsoft C++ Redistributable for Visual Studio 2015, 2017 and 2019" for your platform from this URL: https://support.microsoft.com/help/2977003/the-latest-supported-visual-c-downloads
The list of my installed packages
# Name Version Build Channel
absl-py 0.13.0 pypi_0 pypi
argon2-cffi 20.1.0 pypi_0 pypi
astor 0.8.1 pypi_0 pypi
astunparse 1.6.3 pypi_0 pypi
async-generator 1.10 pypi_0 pypi
attrs 21.2.0 pypi_0 pypi
backcall 0.2.0 pypi_0 pypi
bleach 3.3.1 pypi_0 pypi
ca-certificates 2021.7.5 haa95532_1
cachetools 4.2.2 pypi_0 pypi
certifi 2021.5.30 py36haa95532_0
cffi 1.14.6 pypi_0 pypi
charset-normalizer 2.0.3 pypi_0 pypi
colorama 0.4.4 pypi_0 pypi
cpuonly 1.0 0 pytorch
dataclasses 0.8 pypi_0 pypi
debugpy 1.4.1 pypi_0 pypi
decorator 5.0.9 pypi_0 pypi
defusedxml 0.7.1 pypi_0 pypi
entrypoints 0.3 pypi_0 pypi
flatbuffers 1.12 pypi_0 pypi
gast 0.2.2 pypi_0 pypi
google-auth 1.33.1 pypi_0 pypi
google-auth-oauthlib 0.4.4 pypi_0 pypi
google-pasta 0.2.0 pypi_0 pypi
grpcio 1.34.1 pypi_0 pypi
h5py 2.10.0 pypi_0 pypi
idna 3.2 pypi_0 pypi
importlib-metadata 3.7.3 pypi_0 pypi
ipykernel 6.0.3 pypi_0 pypi
ipython 7.25.0 pypi_0 pypi
ipython-genutils 0.2.0 pypi_0 pypi
ipywidgets 7.6.3 pypi_0 pypi
jedi 0.18.0 pypi_0 pypi
jinja2 3.0.1 pypi_0 pypi
jsonschema 3.2.0 pypi_0 pypi
jupyter 1.0.0 pypi_0 pypi
jupyter-client 6.1.12 pypi_0 pypi
jupyter-console 6.4.0 pypi_0 pypi
jupyter-core 4.7.1 pypi_0 pypi
jupyterlab-pygments 0.1.2 pypi_0 pypi
jupyterlab-widgets 1.0.0 pypi_0 pypi
keras-applications 1.0.8 pypi_0 pypi
keras-nightly 2.5.0.dev2021032900 pypi_0 pypi
keras-preprocessing 1.1.2 pypi_0 pypi
markdown 3.3.4 pypi_0 pypi
markupsafe 2.0.1 pypi_0 pypi
matplotlib-inline 0.1.2 pypi_0 pypi
mistune 0.8.4 pypi_0 pypi
nbclient 0.5.3 pypi_0 pypi
nbconvert 6.1.0 pypi_0 pypi
nbformat 5.1.3 pypi_0 pypi
nest-asyncio 1.5.1 pypi_0 pypi
notebook 6.4.0 pypi_0 pypi
numpy 1.19.5 pypi_0 pypi
oauthlib 3.1.1 pypi_0 pypi
openssl 1.1.1k h2bbff1b_0
opt-einsum 3.3.0 pypi_0 pypi
packaging 21.0 pypi_0 pypi
pandocfilters 1.4.3 pypi_0 pypi
parso 0.8.2 pypi_0 pypi
pickleshare 0.7.5 pypi_0 pypi
pillow 8.3.1 pypi_0 pypi
pip 20.0.2 py36_3
prometheus-client 0.11.0 pypi_0 pypi
prompt-toolkit 3.0.19 pypi_0 pypi
protobuf 3.8.0 pypi_0 pypi
pyasn1 0.4.8 pypi_0 pypi
pyasn1-modules 0.2.8 pypi_0 pypi
pycparser 2.20 pypi_0 pypi
pygments 2.9.0 pypi_0 pypi
pyparsing 2.4.7 pypi_0 pypi
pyrsistent 0.18.0 pypi_0 pypi
python 3.6.8 h9f7ef89_7
python-dateutil 2.8.2 pypi_0 pypi
pywin32 301 pypi_0 pypi
pywinpty 1.1.3 pypi_0 pypi
pyzmq 22.1.0 pypi_0 pypi
qtconsole 5.1.1 pypi_0 pypi
qtpy 1.9.0 pypi_0 pypi
requests 2.26.0 pypi_0 pypi
requests-oauthlib 1.3.0 pypi_0 pypi
rsa 4.7.2 pypi_0 pypi
scipy 1.4.1 pypi_0 pypi
send2trash 1.7.1 pypi_0 pypi
setuptools 52.0.0 py36haa95532_0
six 1.16.0 pypi_0 pypi
sqlite 3.36.0 h2bbff1b_0
tensorboard 2.0.2 pypi_0 pypi
tensorboard-data-server 0.6.1 pypi_0 pypi
tensorboard-plugin-wit 1.8.0 pypi_0 pypi
tensorflow 2.0.0 pypi_0 pypi
tensorflow-estimator 2.0.0 pypi_0 pypi
termcolor 1.1.0 pypi_0 pypi
terminado 0.10.1 pypi_0 pypi
testpath 0.5.0 pypi_0 pypi
torch 1.9.0 pypi_0 pypi
torchaudio 0.9.0 pypi_0 pypi
torchvision 0.10.0 pypi_0 pypi
tornado 6.1 pypi_0 pypi
traitlets 5.0.5 pypi_0 pypi
typing-extensions 3.7.4.3 pypi_0 pypi
urllib3 1.26.6 pypi_0 pypi
vc 14.2 h21ff451_1
vs2015_runtime 14.27.29016 h5e58377_2
wcwidth 0.2.5 pypi_0 pypi
webencodings 0.5.1 pypi_0 pypi
werkzeug 2.0.1 pypi_0 pypi
wheel 0.36.2 pyhd3eb1b0_0
widgetsnbextension 3.5.1 pypi_0 pypi
wincertstore 0.2 py36h7fe50ca_0
wrapt 1.12.1 pypi_0 pypi
zipp 3.5.0 pypi_0 pypi