Python 3.6 - Tensorflow DLL load failed when importing tensorflow - windows

I installed Tensorflow on my command prompt using pip3 on Python 3.6 using:
pip3 install tensorflow==1.5
When checking if I could import tensorflow off the terminal using Python I got the following error message:
Python 3.6.0rc2 (v3.6.0rc2:800a67f7806d, Dec 16 2016, 23:22:07) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\{User}\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import *
File "C:\Users\{User}\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\__init__.py", line 52, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "C:\Users\{User}\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\core\framework\graph_pb2.py", line 6, in <module>
from google.protobuf import descriptor as _descriptor
File "C:\Users\{User}\AppData\Local\Programs\Python\Python36\lib\site-packages\google\protobuf\descriptor.py", line 47, in <module>
from google.protobuf.pyext import _message
ImportError: DLL load failed: The specified procedure could not be found.
What exactly is missing from the DLL?

Are there any issues when installing? Also, why are you installing tensorflow 1.5 when 1.9 is available? I would first try pip uninstall tensorflow and then pip install tensorflow. If you still have issues I would try going here to download the .whl file and then you can do pip install [whatever the filename is].whl. Directly installing these .whl files has solved many a problem for me.
To answer your question, it looks like you are missing descriptor.py from google protobuf. You could try downloading that and moving descriptor.py directly, but my guess is if it can't find one file it's probably missing other things as well.
Looking at other problems with tensorflow imports, it looks like the problem is compatibility with python 3.6 having a divergent path with pip, however it looks like this was solved at some point in the last year. If you're still stuck, of course try upgrading pip, python, and tensorflow; then try downgrading to python 3.5 to see if that works. Best of luck!

Change the protobuf version to pip install protobuf==3.6.0

Related

Python3 cannot find statsmodels.api but I can and so can my linter

I recently got into development with Python running on WSL (Ubuntu 18.04 LTS).
I followed the documentation from here and I'm able to run simple python scripts.
I started playing around with libraries that I installed using the pip3 command such as numpy and pandas and these work fine.
The problem arises when I try to use the statsmodels package.
I've installed it using pip3 install statsmodels
I can see the package in /home/username/.local/lib/python3.6/site-packages/statsmodels I can even see the api.py file in that directory, however, when I type import statsmodels.api as sm as recommended on the statsmodels website I get:
Console output:
username#DESKTOP-1JP4BIE:/mnt/c/users/username/dev/project/playground$ python3 statsmodels.py
Traceback (most recent call last):
File "statsmodels.py", line 5, in <module>
import statsmodels.api as sm
File "/mnt/c/username/chris/dev/project/playground/statsmodels.py", line 5, in <module>
import statsmodels.api as sm
ModuleNotFoundError: No module named 'statsmodels.api'; 'statsmodels' is not a package
I've tried uninstalling and reinstalling (did not work)
I really can't see anything that differentiates this package from the others that I've installed. Does anyone have any insights?
Thanks #Vorsprung durch Technik
The issue was that my file name was statsmodels.py.
I'll remember to be more careful when naming my python files.

Tensorflow install on Windows with anaconda and no internet connection

I can not install Tensorflow on Windows because there in no internet connection based on commpany's security policy.
I just installed anaconda and python by transmiting files with intranet.
Please let me know how to install that with no internet connection.
==========================================================================
In addition, when I used the below command after installing tensorflow, I found
other problems..
Python 3.5.2 |Anaconda 4.2.0 (64-bit)| (default, Jul 5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Daisy\Anaconda3\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import *
File "C:\Users\Daisy\Anaconda3\lib\site-packages\tensorflow\python\__init__.py", line 63, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "C:\Users\Daisy\Anaconda3\lib\site-packages\tensorflow\core\framework\graph_pb2.py", line 6, in <module>
from google.protobuf import descriptor as _descriptor
ImportError: No module named 'google'
I don't know how to solve this one.
If you can download the whl file and transfer it to your workstation, then you can run:
pip.exe install --upgrade --no-deps <tensorflow whl file name>
This should avoid trying to connect to download tensorflow dependencies, as anaconda already has most of these.

OpenCV - python 3.x and windows - what version of Numpy?

I downloaded openCV from http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv and installed it. When I tried to run it:
import cv2
I got error message:
RuntimeError: module compiled against API version a but this version of numpy is 9
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition
5.0.3\helpers\pydev\pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
ImportError: numpy.core.multiarray failed to import
I guess I need to set up virtual enviroment and install different version of Numpy, but what exact version of Numpy I need to install?
You can try using the anaconda distribution for that.
I'm using it and it works great with opencv on windows.
You can download it from here:
https://www.continuum.io/downloads
Then use conda to install opencv
conda install -c conda-forge opencv
conda comes with pre installed numpy, scipy, pandas etc and makes deployment on windows painless (since it ships with the build-chain).
You need numpy version 11 or above . You can find it in the below link.
https://pypi.python.org/pypi/numpy

Wand does not work under python 64 bit and imagemagick 64 bit: cannot find shared libraries

I am running python 2.7 64bit on windows and have installed imagemagick 64 bit (latest version available) with the necessary headers and env variables as stated in the guide. Unfortunately I am able to install wand via pip but as soon as I try to use wand I get this error:
>>> from wand.image import Image
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\wand\image.py", line 20, in <module>
from .api import MagickPixelPacket, libc, libmagick, library
File "C:\Python27\lib\site-packages\wand\api.py", line 205, in <module>
'Try to install:\n ' + msg)
ImportError: MagickWand shared library not found.
You probably had not installed ImageMagick library.
Try to install:
http://docs.wand-py.org/en/latest/guide/install.html#install-imagemagick-on-wi
ndows
Has anyone experienced this issue? Thanks in advance.
Install the version: ImageMagick-6.9.8-9-Q16-x64-dll.exe
Wand doesn't support the latest version as of yet.

Version upgrade to scikit-learn

I wanted to do LDA on some data and so followed this example:
http://scikit-learn.org/stable/auto_examples/decomposition/plot_pca_vs_lda.html#example-decomposition-plot-pca-vs-lda-py
however, on trying:
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
I got an import error. Huh, maybe this is a new function, I thought. So I updated scikit-learn via conda from 0.15.2 to 0.17. But now I can't even import sklearn:
import sklearn
RuntimeError: module compiled against API version a but this version of numpy is 9
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "//anaconda/lib/python2.7/site-packages/sklearn/__init__.py", line 57, in <module>
from .base import clone
File "//anaconda/lib/python2.7/site-packages/sklearn/base.py", line 9, in <module>
from scipy import sparse
File "//anaconda/lib/python2.7/site-packages/scipy/sparse/__init__.py", line 213, in <module>
from .csr import *
File "//anaconda/lib/python2.7/site-packages/scipy/sparse/csr.py", line 13, in <module>
from ._sparsetools import csr_tocsc, csr_tobsr, csr_count_blocks, \
ImportError: numpy.core.multiarray failed to import
I tried updating numpy and scipy using both pip and conda to no avail. I then tried a complete clean re-install of anaconda by:
rm -rf ~/anaconda
and a subsequent download of the .pkg from http://docs.continuum.io/anaconda/install#anaconda-install
Still I get the same error. Here are my OS and package details:
Mac OSX 10.5.2
bash-3.2$ conda -V
conda 3.18.6
scipy==0.16.0
numpy==1.9.1
scikit-learn==0.17
The last of these via pip freeze since I can't import it. I'm going nuts here. Any help much appreciated.
Try:
conda install numpy=1.10.1
I've had that module compiled against API version a but this version of numpy is 9 error before, and this solved it for me.

Resources