On Windows, running "import tensorflow" generates No module named "_pywrap_tensorflow" error - tensorflow

On Windows, TensorFlow reports either or both of the following errors after executing an import tensorflow statement:
No module named "_pywrap_tensorflow"
DLL load failed.

The problem was the cuDNN Library for me - for whatever reason cudnn-8.0-windows10-x64-v6.0 was NOT working - I used cudnn-8.0-windows10-x64-v5.1 - ALL GOOD!
My setup working with Win10 64 and the Nvidia GTX780M:
Be sure you have the lib MSVCP140.DLL by checking your system/path - if not get it here
Run the windows installer for python 3.5.3-amd64 from here - DO NOT try newer versions as they probably won't work
Get the cuDNN v5.1 for CUDA 8.0 from here - put it under your users folder or in another known location (you will need this in your path)
Get CUDA 8.0 x86_64 from here
Set PATH vars as expected to point at the cuDNN libs and python (the python path should be added during the python install)
Make sure that ".DLL" is included in your PATHEXT variable
If you are using tensorflow 1.3 then you want to use cudnn64_6.dll github.com/tensorflow/tensorflow/issues/7705
If you run Windows 32 be sure to get the 32 bit versions of the files mentioned above.

In my case the "cudnn64_6.dll" file in the /bin folder had to be renamed to "cudnn64_5.dll" for the error to go away. I easily spent two hours to figure this out, and I followed the official install guide to the letter. This is true for installation via pip (officially supported) and conda (community supported).

Either error indicates that your system has not installed MSVCP140.DLL,
which TensorFlow requires.
To fix this error:
Determine whether MSVCP140.DLL is in your %PATH% variable.
If MSVCP140.DLL is not in your %PATH%, install the
Visual C++ 2015 redistributable (x64 version), which contains this DLL.

I have Win7 Pro 64-bit on AMD cpu, no gpu. I was following the instructions under "Installing with native pip" at https://www.tensorflow.org/install/install_windows. The installation step went ok but the attempt to import tensorflow produced the infamous:
ImportError: No module named '_pywrap_tensorflow_internal'
This seems to be one of those situations where a lot of unrelated things can go wrong, depending on configuration, which all cascade through to the same error.
In my case, installing MSVCP140.DLL was the answer.
You have MSVCP140.DLL already if
you have a file C:\Windows\System32\MSVCP140.DLL, AND
if you have a 64 bit system, then you additionally have C:\Windows\SysWOW64\MSVCP140.DLL.
I installed it manually, which was unnecessary (the redistributable is not the whole Visual C++ development mess and isn't large). Use the link posted earlier in this thread to install it: Visual C++ 2015 redistributable.
Also, I recommend that you override the default install directory for Python and put it anywhere not under C:\Program Files, because Windows tries to write-protect files there, which causes problems later.

For tensorflow with CPU only:
I had installed tensorflow using command:
pip3 install --upgrade tensorflow
This installed tensorflow 1.7
But could not import the tensorflow from withing python 3.6.5 amd64 using:
import tensorflow as tf
So, i downgraded the tensorflow version from 1.7 to 1.5 using following command:
pip3 install tensorflow==1.5
This uninstalled the previous version and installed 1.5. Now it works.
Seems that, my CPU does not support AVX instruction set that is needed in tensorflow 1.7
I had MSVCP140.DLL in the system folders and .DLL in the PATHEXT variable in Environment Variable.

TensorFlow requires MSVCP140.DLL, which may not be installed on your system.
To solve it open the terminal en type or paste this link:
C:\> pip install --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.0.0-cp35-cp35m-win_amd64.whl
Note this is to install the CPU-only version of TensorFlow.

cuDNN causes my problem. PATH variable doesn't work for me. I have to copy the files in my cuDNN folders into respectful CUDA 8.0 folder structure.

For Those Running on Older Hardware:
You may get this same error due to having an older CPU using tensorflow-gpu 1.6.
If your cpu was made before 2011, then your max tensorflow-gpu version is 1.5.
Tensorflow 1.6 requires AVX instructions on your cpu. Verified here: Tensorflow Github docs
AVX enabled CPUs: Wiki AVX CPUs
What I did in my conda environment for tensorflow:
pip install --ignore-installed --upgrade tensorflow-gpu==1.5

I posted a general approach for troubleshooting the "DLL load failed" problem in this post on Windows systems. For reference:
Use the DLL dependency analyzer Dependencies to analyze <Your Python Dir>\Lib\site-packages\tensorflow\python\_pywrap_tensorflow_internal.pyd and determine the exact missing DLL (indicated by a ? beside the
DLL). The path of the .pyd file is based on the TensorFlow 1.9 GPU
version that I installed. I am not sure if the name and path is the
same in other TensorFlow versions.
Look for information of the missing DLL and install the appropriate package to resolve the problem.

The problem for me was the cuDNN library which didn't match the requirements of the graphics card. I downloaded the 6.0 version but for my GTX980ti but the recommended compute capability on the nvidia website was 5.1 ( http://developer.nvidia.com/cuda-gpus ) so I downloaded 5.1 and replaced the 6.0 version and as soon as I've done that it started working.

After much trial and error, and making sure VC++ 2015 Redistributable, cuDNN DLL and all other dependencies are accessible from PATH, it looks like Tensorflow GPU works only with Python 3.5.2 (as of this writing)
So if you're using Anaconda
conda create -n tensorflow-gpu python=3.5.2
activate tensorflow-gpu
pip install tensorflow-gpu
Then open the python interpreter and verify
>>> import tensorflow as tf
>>> sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
Found device 0 with properties:
name: GeForce 940M
major: 5 minor: 0
memoryClockRate (GHz) 1.176
pciBusID 0000:06:00.0
Total memory: 2.00GiB
Free memory: 1.66GiB
Credits: this neat guide

For each Tensorflow's version, it requires different version of CuDnn. On www.tensorflow.org, they did not mentioned about that in installation guide!
My case use tensorflow version 1.3 which uses cuDNN 6. https://github.com/tensorflow/tensorflow/releases.
Please check your tensorfow version and cuDNN version if they are match together.
And please set path environment for cuDNN, if it still does not work, please check the answer from #Chris Han.

One may be tempted to keep the Powershell/cmd open on Windows. I've spent reasonable time till I decided to close and reopen my Powershell only to realize that I've done everything right.

In case you are trying to install tensorflow GPU in Windows, you can find this easy interesting tutorial.
Note: If you are using PyCharm for example, you have to change the interpreter to the created conda environment.

For the people finding this post in 2019, this error could also occur because the Python version 3.7 does not have support for TensorFlow (see https://www.tensorflow.org/install/pip). So, check the Python version:
python --version
In case it is larger than 3.6, it should be downgraded to 3.6. For Anaconda:
conda install python=3.6
Then, install TensorFlow.
pip install tensorflow
Btw, I did not have the GPU version, so there were no CUDA related issues in my case.

Dll not found. Install Visual C++ 2015 redistributable to fix.

The problem was the cuDNN Library for me. I was able to run the test code after adding the directory (possibly bin folder) of the cuDNN DLL (not LIB file) in the Windows PATH.
For the reference, I installed TensorFlow from the source using PIP and my OS: Windows 7 and IDE: Visual Studio 2015.

With TensorFlow release 1.3.0, you need to use Cudnn 6.0 instead of Cudnn 5.0 as Cudnn 5.0 is giving this error. Don't forget to add path variable to Cudnn 6.0 .With cudnn64_6.dll your Tensorflow will work fine. Read the link below.
https://github.com/tensorflow/tensorflow/blob/master/RELEASE.md#release-130

My two cents:
I had a ton of problems trying to get my CUDA 8.0 installed properly on Windows 7. I had a previous version installed and I wanted to upgrade so I uninstalled it and tried to install CUDA 8.0 (for tensorflow 1.3). The installation failed every single time, I tried to downgrade to CUDA 7.5 and was able to install it but had a ton of problems with tensorflow (similar to the PATH problem described here). Long story short: what worked for me was:
1) Uninstall EVERY NVIDIA component (except the display graphics driver)
2) Download CUDA toolkit 8.0 (and the patch) https://developer.nvidia.com/cuda-downloads
3) Check the CheckSum MD5 (I used MS https://www.microsoft.com/en-ca/download/confirmation.aspx?id=11533 but any would do) to make sure they were OK (it happened several times that the installer was not dowloaded properly because my WiFi router apparently).
4) Run the CUDA toolkit installer as root
5) download the cudnn 8.0 v6 and add its location to the PATH variable https://developer.nvidia.com/rdp/cudnn-download
Hope that helps and saves some headaches...
NOTE: This script helped me a lot to debug the problem! (Thank you mrry)
https://gist.github.com/mrry/ee5dbcfdd045fa48a27d56664411d41c

I will try to give the solution that worked for me. It seems that different set of problems can lead to this situation.
32 bit software works in 64 bit OS. I installed anaconda-3 (32 bit) in my 64 bit OS. It was working perfectly fine. I decided to install tensorflow in my machine and it wouldn't install at first. I was using conda environment to install tensorflow and got this error.
Solution is if you are running 64 bit OS, install 64 bit anaconda and if 32 bit OS then 32 bit anaconda. Then follow the standard procedure mentioned in tensorflow website for windows (anaconda installation). This made it possible to install tensorflow without any problem.

my answer is for windows 10 users only as I have tried the following on windows 10.
Extending some of the answers above I suggest this :
If you are using anaconda then you can avoid everything and simply install anaconda-navigator using the command
conda install -c anaconda anaconda-navigator
Then you can launch the navigator from command prompt using the command
anaconda-navigator
On running this command you get a simple gui where you can create an virtual environment, create the environment with python=3.5.2 and install module tensorflow-gpu or tensorflow by searching the module in the search box using gui, it will also take care of installing correct cuda files for you. Using anaconda navigator is the simplest solution.
If you are not using anaconda then take care about the following
tensorflow-gpu 1.3 requires python 3.5.2, cuda development kit 8.0 and cudaDNN 6.0, hence when installing make sure you run the command
pip install tensorflow-gpu==1.3
tensorflow-gpu 1.2.1 or less requires python 3.5.2, cuda development kit 8.0 and cudaDNN 5.1 hence when installing make sure you run the command
pip install tensorflow-gpu==1.2.1
Below are the steps you need to follow for both of the above processes
Setting up you path variables
You must have the following system variables
CUDA_HOME = "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0"
CUDA_PATH = "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0"
CUDA_PATH_V8.0 = "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0"
You PATHTEXT must include ".DLL" along with other extensions
".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY;.DLL"
Also Add the following to you path
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\lib\x64
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\extras\CUPTI\libx64;
C:\Windows\SysWOW64;
C:\Windows\System32
If you are getting errors you can download the run the below code by mrry, this code will check your setup and tell you if something is wrong
https://gist.github.com/mrry/ee5dbcfdd045fa48a27d56664411d41c
References :
http://blog.nitishmutha.com/tensorflow/2017/01/22/TensorFlow-with-gpu-for-windows.html
The above reference is very useful.
Please comment for improvements to this answer.
Hope this helps, Thanks.

tensorflow 1.3 does not support cuda 9.0 yet.
I degrade to cuda 8.0, then it works.

Ran into the same problem (in 20190909) while investigating [SO]: Error while training using the estimator API in tensorflow.
Setup:
Win 10 pc064
Python 3.7.3 (pc064)
TensorFlow-GPU 1.13.1 ([TensorFlow]: Install TensorFlow with pip)
Error:
[cfati#CFATI-5510-0:e:\Work\Dev\StackOverflow\q057588589]> "e:\Work\Dev\VEnvs\py_064_03.07.03_test0\Scripts\python.exe" -c "import tensorflow as tf"
Traceback (most recent call last):
File "e:\Work\Dev\VEnvs\py_064_03.07.03_test0\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "e:\Work\Dev\VEnvs\py_064_03.07.03_test0\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "e:\Work\Dev\VEnvs\py_064_03.07.03_test0\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 "e:\Work\Dev\VEnvs\py_064_03.07.03_test0\lib\imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "e:\Work\Dev\VEnvs\py_064_03.07.03_test0\lib\imp.py", line 342, in load_dynamic
return _load(spec)
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 "<string>", line 1, in <module>
File "e:\Work\Dev\VEnvs\py_064_03.07.03_test0\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "e:\Work\Dev\VEnvs\py_064_03.07.03_test0\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "e:\Work\Dev\VEnvs\py_064_03.07.03_test0\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "e:\Work\Dev\VEnvs\py_064_03.07.03_test0\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "e:\Work\Dev\VEnvs\py_064_03.07.03_test0\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "e:\Work\Dev\VEnvs\py_064_03.07.03_test0\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 "e:\Work\Dev\VEnvs\py_064_03.07.03_test0\lib\imp.py", line 242, in load_module
return load_dynamic(name, filename, file)
File "e:\Work\Dev\VEnvs\py_064_03.07.03_test0\lib\imp.py", line 342, 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.
Looking at the "faulty" module (thanks to Dependency Walker), it turns out that it's not itself that's missing, but some of its dependencies (the cu*_100.dll files).
Check [SO]: Python Ctypes - loading dll throws OSError: [WinError 193] %1 is not a valid Win32 application (#CristiFati's answer) (the Conclusions section at the end, and (referenced) [SO]: Discover missing module using command-line ("DLL load failed" error) (#CristiFati's answer)) for more details on this kind of errors.
I had an older CUDA Toolkit version (8), and as a consequence, the cu*_80.dll files.
Upgrading to TensorFlow-GPU 1.14.0 ("e:\Work\Dev\VEnvs\py_064_03.07.03_test0\Scripts\python.exe" -m pip install --upgrade tensorflow-gpu), made the error a bit clearer (and also shorter):
[cfati#CFATI-5510-0:e:\Work\Dev\StackOverflow\q057588589]> "e:\Work\Dev\VEnvs\py_064_03.07.03_test0\Scripts\python.exe" -c "import tensorflow as tf"
Traceback (most recent call last):
File "e:\Work\Dev\VEnvs\py_064_03.07.03_test0\lib\site-packages\tensorflow\python\platform\self_check.py", line 75, in preload_check
ctypes.WinDLL(build_info.cudart_dll_name)
File "c:\install\x64\python\python\03.07.03\Lib\ctypes\__init__.py", line 356, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "e:\Work\Dev\VEnvs\py_064_03.07.03_test0\lib\site-packages\tensorflow\__init__.py", line 28, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "e:\Work\Dev\VEnvs\py_064_03.07.03_test0\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "e:\Work\Dev\VEnvs\py_064_03.07.03_test0\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 30, in <module>
self_check.preload_check()
File "e:\Work\Dev\VEnvs\py_064_03.07.03_test0\lib\site-packages\tensorflow\python\platform\self_check.py", line 82, in preload_check
% (build_info.cudart_dll_name, build_info.cuda_version_number))
ImportError: Could not find 'cudart64_100.dll'. TensorFlow requires that this DLL be installed in a directory that is named in your %PATH% environment variable. Download and install CUDA 10.0 from this URL: https://developer.nvidia.com/cuda-90-download-archive
Steps:
Uninstall any CUDA Toolkit version (optional)
Install [nVidia.Developer]: CUDA Toolkit 10.0 Archive
Make sure to install v10.0 (that this TensorFlow-GPU version was built against - check [TensorFlow]: Build from source on Windows - GPU). I installed v10.1 (which was the latest, and also the recommended version at the answer time), and the .dll names didn't match (cu*_101.dll). Since I didn't want to install v10.0, I created some symlinks (with the "correct" names) to the existing files, and it worked. But bear in mind that this is unsupported!!! You may experience funny behavior (including crashes). This is a (lame) workaround (gainarie)
Additionally, a compatible (meaning that it's for a specific CUDA Toolkit version) cuDNN version ([nVidia.Developer]: cuDNN Archive) is required. In order to access the download URL, nVidia membership is required
After the above steps, and also setting the correct paths, it worked:
[cfati#CFATI-5510-0:e:\Work\Dev\StackOverflow\q057588589]> set PATH=%PATH%;%CUDA_PATH%\bin;f:\Install\x64\NVidia\GPU Computing Toolkit\cuDNN\7.6\bin
[cfati#CFATI-5510-0:e:\Work\Dev\StackOverflow\q057588589]> "e:\Work\Dev\VEnvs\py_064_03.07.03_test0\Scripts\python.exe" -c "import tensorflow;print(\"Success!!!\")"
Success!!!

Related

Application Spyder launch may have produced errors Mac M1 Chip

Hey dear I am trying to launch spyder on my anaconda environment but I face this errors.
Application Spyder launch may have produced errors Mac M1 Chip
Traceback (most recent call last):
File "/Users/nawrozmohammadi/miniforge3/envs/tf24/bin/spyder", line 7, in
from spyder.app.start import main
File "/Users/nawrozmohammadi/miniforge3/envs/tf24/lib/python3.8/site-packages/spyder/app/start.py", line 35, in
from spyder.utils.external import lockfile
File "/Users/nawrozmohammadi/miniforge3/envs/tf24/lib/python3.8/site-packages/spyder/utils/external/lockfile.py", line 31, in
from spyder.utils.programs import is_spyder_process
File "/Users/nawrozmohammadi/miniforge3/envs/tf24/lib/python3.8/site-packages/spyder/utils/programs.py", line 30, in
import psutil
File "/Users/nawrozmohammadi/miniforge3/envs/tf24/lib/python3.8/site-packages/psutil/__init__.py", line 159, in
from . import _psosx as _psplatform
File "/Users/nawrozmohammadi/miniforge3/envs/tf24/lib/python3.8/site-packages/psutil/_psosx.py", line 15, in
from . import _psutil_osx as cext
ImportError: dlopen(/Users/nawrozmohammadi/miniforge3/envs/tf24/lib/python3.8/site-packages/psutil/_psutil_osx.cpython-38-darwin.so, 2): no suitable image found. Did find:
/Users/nawrozmohammadi/miniforge3/envs/tf24/lib/python3.8/site-packages/psutil/_psutil_osx.cpython-38-darwin.so: mach-o, but wrong architecture
/Users/nawrozmohammadi/miniforge3/envs/tf24/lib/python3.8/site-packages/psutil/_psutil_osx.cpython-38-darwin.so: mach-o, but wrong architecture
**Befor I launch spyder I installed Tensorflow through these two ways
first and second and Tensorflow working successfully **
>>>import tensorflow as tf
>>>tf.__version__
'2.4.0-rc0'
I have tried installing pyqt and did
conda update --all
.But nothing works
System info
conda version : 4.9.2
python version: 3.8.6
platform : maOS BigSur 64
Anaconda runs on x86 (intel) hence even i have faced many issues with the m1 macbook air. But miniconda is specifically tailored for arm64 chips.
hence try to install miniconda and use jupyternotebooks.
Follow the below guide to install tensorflow and Pycharm successfully:
Installation of TensorFlow & Pytorch on M1 Macbooks

i successfully installed tensorflow in anaconda prompt, but unable import in jupyter notebook

ERROR: Failed to import the TensorFlow module.
Reason: Traceback (most recent call last):
File "C:\Users\pratap\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: 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.
Python version is 3.8.
The official distribution of TensorFlow for Windows requires Python version 3.5 or 3.6.
TensorFlow is installed at: C:\Users\pratap\Anaconda3\lib\site-packages\tensorflow
msvcp140.dll Found at C:\Users\pratap\Anaconda3\msvcp140.dll
Could not load 'cudart64_90.dll'. Download and install CUDA 9.0 from
this URL: https://developer.nvidia.com/cuda-toolkit
Could not load 'nvcuda.dll'. The GPU version of TensorFlow requires that
this DLL be installed in a directory that is named in your %PATH%
environment variable. Typically it is installed in 'C:\Windows\System32'.
If it is not present, ensure that you have a CUDA-capable GPU with the
correct driver installed.
Could not load 'cudnn64_7.dll'. The GPU version of TensorFlow
requires that this DLL be installed in a directory that is named in
your %PATH% environment variable. Note that installing cuDNN is a
separate step from installing CUDA, and it is often found in a
different directory from the CUDA DLLs. You may install the
necessary DLL by downloading cuDNN 7.0 for Cuda 9.0 from this URL:
https://developer.nvidia.com/cudnn
An exception has occurred, use %tb to see the full traceback.
SystemExit: -1
Tensorflow supports python3.8 starting from version 2.2.
I would recommend running conda install python=3.6 and taking it from there.

Tensorflow-gpu 1.5 with cuda 8.0 and cudnn v7.1 for cuda 8.0

I first installed cuda 9.0 and cudnn for cuda 9.0 and the latest tensorflow-gpu 1.6. But I noticed my nvidia-driver 384.111 doesn't support cuda 9.0. SO I uninstalled cuda 9.0, cudnn and tensorflow-gpu 1.5 and reinstalled tensorflow-gpu 1.5, cuda8.0 and cudnn v7.1 for cuda 8.0. But when I import tensorflow, it always shows:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory
Failed to load the native TensorFlow runtime.
Seems like tensorflow is trying to find libcublas.so.9.0 however I only have cuda 8.0 installed. It's clear that I can use tensorflow 1.5 with cuda 8.0.
Does anyone know how to solve this?
Update:
Looks like tensorflow officially doesn't provide binaries compiled with cuda 8.0 and cudnn v7.1 after tensorflow 1.4. Does any one know where to download those binaries?
I assume that you are installing TF using pip install. Tensorflow install page (currently, version 1.6) mentions than that CUDA® Toolkit 9.0 along with cuDNN v7.0 are the requirements for your installation.
Since TF version 1.5 CUDA9+CUDNN7 are among new requirements. Since CUDA9 relies on NVIDIA driver 384+ it causes a chain of updates of software: driver, CUDA, CUDNN, TF, etc. CUDA 9.1 would require nvidia driver 390 or later.
Ways to solve the issue you can follow one of following paths:
Update nvidia driver and switch back to CUDA 9.0 and cuDNN 7.0. You can have multiple versions of CUDA and CUDNN coexisting on your system.
Install TF 1.4 which requires exactly CUDA 8.0 and cuDNN v6.0
Compile TF from source. It requires investing some time and installing additional software. In my experience can easily take hours even if it is not your first time.
Find a wheel of TF compiled for your system configuration.
I have had the same problem when installing tensorflow-gpu-1.6, i have resolved my problem like this :
step(1): for tensorflow-gpu-1.6 we can use cuda9.0 and cudnn7 so download cuda9.0 debian if you are using Ubuntu, you can download cuda9.0 from here https://developer.nvidia.com/cuda-90-download-archive
step(2): enter the following command sudo apt-get --purge remove cuda
step(3): sudo apt autoremove
step(4): and now install the downloaded cuda9.0 file
step(5): and nvidia driver 384 is ok for cuda9.0, so no worries
step(6): edit the path for cuda9.0 in bashrc gedit ~/.bashrc
I have done the same procedure like i removed every thing related to cuda from my pc, and then tried installing cuda9.0 and it did worked for me.
Let me know whether problem is resolved or not, Thank You.

How can I install mpmath as an external library for Blender?

I'm interested in trying out sympy with Blender (v2.76, Python 3.4.2 Console, Windows 8.1). I followed this answer from Blender SE, downloaded sympy as a ZIP from Githib, and moved the sympy folder to C:\Program Files\Blender Foundation\Blender\2.76\python\lib\site-packages. However, when I opened Blender and tried to import sympy in the Python Console, I got the following error:
>>> import sympy
Traceback (most recent call last):
File "<blender_console>", line 1, in <module>
File "C:\Program Files\Blender Foundation\Blender\2.76\python\lib\site-packages\sympy\__init__.py", line 20, in <module>
raise ImportError("SymPy now depends on mpmath as an external library. "
ImportError: SymPy now depends on mpmath as an external library. See http://docs.sympy.org/latest/install.html#mpmath for more information.
I don't know how to install an external library. I tried going to the link mentioned in the ImportError, and I saw pip install mpmath. I tried it in cmd, but got this:
>pip install mpmath
Requirement already satisfied (use --upgrade to upgrade): mpmath in c:\anaconda3
\lib\site-packages
I did install Anaconda a while ago, so I guess it makes sense to have this output. How can I install mpmath as an external library for Blender so I can import sympy in it?
You want to install mpmath into blenders python folder, the same as you have done for sympy.
Your example of running pip was done in a system installed python that is setup to find the mpmath that you have installed in c:\anaconda3\lib\site-packages
Another option is to use the existing install of mpmath and sympy by adding your existing path to sys.path or adding it to the PYTHONPATH environment variable before you start blender.

import cvxopt.base: the specified module could not be found

I'm new to Python, just installed cvxopt module for my Python3.3 system (64 bit). The installation was successful, but when I typed "import cvxopt" in Python command line, it returned an error:
File "C:\Program Files
(x86)\Python\lib\site-packages\cvxopt__init__.py", line 33, in
import cvxopt.base ImportError: DLL load failed: The
specified module could not be found.
Could anyone help me on this problem? Thanks a lot!
You need to import numpy first before importing cvxopt.
import numpy
import cvxopt
The package CVXOPT requires numpy+mkl, you can try uninstall the numpy package and reinstall numpy+mkl from http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy, then importing the CVXOPT, it will work.
You need to add YourPythonPath\Library\bin to your PATH environment variable. In my case it is C:\Python36-64\Library\bin
The reason for the dll load problem is most likely a very different one. The most up to date Anaconda version (e.g. Anaconda 5.0.1) has Numpy with MKL support. This is NOT the issue. I verified this by looking at the installed packages using conda list. The issue is the fact that cvxopt requires some dlls, which are in the directory
C:\Anaconda3\envs\foo\Library\mingw-w64\bin
If you install Anaconda and do NOT register Anaconda python on the system path (which is their suggested setup anyway) and then use the Anaconda prommpt to set up a new environment (note for current verison of cvxopt you need Python 3.5)
conda create -n foo python=3.5
activate foo
conda install cvxopt
and importing cvxopt
(foo) C:\tmp>python
Python 3.5.4 |Anaconda, Inc.| (default, Nov 8 2017, 14:34:30) [MSC v.1900
64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cvxopt
>>>
all should work fine. If you check the Anaconda related path settings you will find
C:\Anaconda3\envs\foo;
C:\Anaconda3\envs\foo\Library\mingw-w64\bin;
C:\Anaconda3\envs\foo\Library\usr\bin;
C:\Anaconda3\envs\foo\Library\bin;
C:\Anaconda3\envs\foo\Scripts;
If you now remove C:\Anaconda3\envs\foo\Library\mingw-w64\bin from the path you are back to the problem
C:\tmp>python
Python 3.5.4 |Anaconda, Inc.| (default, Nov 8 2017, 14:34:30) [MSC v.1900
64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import cvxopt
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Anaconda3\envs\tf14\lib\site-packages\cvxopt\__init__.py", line 32, in <module>
import cvxopt.base
ImportError: DLL load failed: The specified module could not be found.
>>>
However there is another issue, related to PyCharm: how to actually use Anaconda envs properly with PyCharm? PyCharm cannot handle additional paths as required by an environment. At leat not out of the box, or I did not find a way to properly do it. Any suggestions are welcome.
I fixed it. Just add path C:\Python36\Library\bin to PATH environment variable the same as Artashes Khachatryan said.
When I imported cvxopt library, it run base.cp36-win_amd64 file and this file requires dll in bin folder.
cvxopt.base is built as a pyd file (essentially a Windows DLL). It should be located in "C:\Program Files (x86)\Python\lib\site-packages\cvxopt". Check that this directory is in your PYTHONPATH. If it isn't, you can append the directory to your path from the command line as follows:
import sys
sys.path.append("C:\Program Files (x86)\Python\lib\site-packages\cvxopt")
Hope that helps!
I had the same issue of ImportError while importing cvxopt module. Since cvxopt supports python version 2.7-3.5, I created a conda virtual environment first with python 3.5 using the steps below:
open Anaconda Prompt
conda create -n python=3.5
conda activate
In the activated conda environment install cvxopt package using command:
conda install cvxopt
This will install the cvxopt package and all the dependencies.
After installation open spyder by typing spyder in the Anaconda prompt and this will open Spyder with the virtual environment that you have created.
After this cvxopt package will work without any errors.
Note: I have been trying to open the virtual environment in Pycharm but that didn't work and in the end switched to spyder.
I had the same issue and what fixed it was to move to python 3.5 (by creating a virtual environment). Note that cvxopt does not work unfortunately with python 3.6.
I encountered this issue when working in PyCharm 2018.1 in combination with a Conda environment. When I run the following from the Anaconda terminal, everything works fine:
conda activate cvxopt_test
python -c "import cvxopt"
However, when running import cvxopt in PyCharm the error you describe is raised. As Daniel mentioned in his anwser, this has to do with the windows PATH variable (os.environ['PATH']). Somehow PyCharm does not add the cvxopt folders when running the code. For me the minimal working example to avoid the error was:
import os
# add the folder containing the DLL to the PATH variable
os.environ['PATH'] += r';C:\Anaconda3\envs\foo\Library\mingw-w64\bin'
Although it might be wise to add all the folders Daniel mentions to the PATH variable in the same way.
Open the System Properties window and click on the Advanced tab.
Click the Environment Variables button at the bottom.
In the User variables section, select Path and click Edit.
Add the directory that contains mkl_rt.dll to the path.