TensorFlow in Visual Studio 2015, using Canopy as the Python environment - python

I followed the instructions on this page and managed to install TensorFlow via pip within Visual Studio 2015. My Python environment runs in Enthought Canopy. The installation was successful. I refreshed the DB, and auto-completion via IntelliSense was available when I wrote the following line:
from tensorflow.examples.tutorials.mnist import input_data
However, when I run it in the REPL, I see the following error message:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\User\AppData\Local\Enthought\Canopy\User\lib\site-packages\tensorflow\__init__.py", line 23, in <module>
from tensorflow.python import *
File "C:\Users\User\AppData\Local\Enthought\Canopy\User\lib\site-packages\tensorflow\python\__init__.py", line 49, in <module>
from tensorflow import contrib
File "C:\Users\User\AppData\Local\Enthought\Canopy\User\lib\site-packages\tensorflow\contrib\__init__.py", line 23, in <module>
from tensorflow.contrib import layers
File "C:\Users\User\AppData\Local\Enthought\Canopy\User\lib\site-packages\tensorflow\contrib\layers\__init__.py", line 68, in <module>
from tensorflow.contrib.layers.python.layers import *
File "C:\Users\User\AppData\Local\Enthought\Canopy\User\lib\site-packages\tensorflow\contrib\layers\python\layers\__init__.py", line 22, in <module>
from tensorflow.contrib.layers.python.layers.initializers import *
File "C:\Users\User\AppData\Local\Enthought\Canopy\User\lib\site-packages\tensorflow\contrib\layers\python\layers\initializers.py", line 24, in <module>
from tensorflow.python.ops import random_ops
File "C:\Users\User\AppData\Local\Enthought\Canopy\User\lib\site-packages\tensorflow\python\ops\random_ops.py", line 23, in <module>
from tensorflow.python.framework import ops
File "C:\Users\User\AppData\Local\Enthought\Canopy\User\lib\site-packages\tensorflow\python\framework\ops.py", line 39, in <module>
from tensorflow.python.framework import versions
File "C:\Users\User\AppData\Local\Enthought\Canopy\User\lib\site-packages\tensorflow\python\framework\versions.py", line 22, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\User\AppData\Local\Enthought\Canopy\User\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 28, in <module>
_pywrap_tensorflow = swig_import_helper()
File "C:\Users\User\AppData\Local\Enthought\Canopy\User\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 20, in swig_import_helper
import _pywrap_tensorflow
ImportError: No module named _pywrap_tensorflow
Can anyone shed some light on why I get the message ImportError: No module named _pywrap_tensorflow even though the installation of TensorFlow took place without a hiccup? Any suggestions on how I can resolve this issue?

The current version of TensorFlow does not support running on Windows. In particular, the PIP packages available here are for Linux and Mac OS X only: they include a native compiled library called _pywrap_tensorflow that has not been compiled for Windows.
As suggested in another answer, you can run TensorFlow on Windows using a Docker container. There is an open issue on GitHub concerning better Windows support, but this will depend on Bazel adding support for Windows build (currently targeted for later this year).

Related

Importing Tensorflow giving weird errors

I am trying to learn tensor flow but when I import tensor flow
import tensorflow
it gives errors regarding pywrap
File "<stdin>", line 1, in <module>
File "C:\Users\rakti\anaconda\lib\site-packages\tensorflow\__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "C:\Users\rakti\anaconda\lib\site-packages\tensorflow\python\__init__.py", line 40, in <module>
from tensorflow.python.eager import context
File "C:\Users\rakti\anaconda\lib\site-packages\tensorflow\python\eager\context.py", line 35, in <module>
from tensorflow.python import pywrap_tfe
File "C:\Users\rakti\anaconda\lib\site-packages\tensorflow\python\pywrap_tfe.py", line 28, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\rakti\anaconda\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 83, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\rakti\anaconda\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed: The specified module could not be found.
Failed to load the native TensorFlow runtime.
can anyone tell me what I have done worng.
or what can I do to recover from this situation?
i have already installed cudnn and cudatoolkit
via these command line commands
conda install cudatoolkit
conda install cudnn
so they may not be the focus of this problem
Try installing Microsoft Visual C++ Redistributable für Visual Studio 2019 it can solve your issue because as of my research most of the places I saw, had this solution only.
If you want to know how to download it you can search google or bing about it.
Please comment if this doesn't help, I'll try to help you and make sure to install tensor flow again.

Installing Tensorflow (cpu) on Jenkins agent

To run our tests on Jenkins, we need to install tensorflow in the virtual environment inside the Jenkins agent. I am getting the following error.
import tensorflow as tf
File "/prod/msp/build/slave1/workspace/Jobs_uiuc_simplesilo_master-7ENH27JSQENY42PFYNEOG3SJGXLTHWJC5Z6KNZUHEDUIGUWU5ZHQ/venv2/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/prod/msp/build/slave1/workspace/Jobs_uiuc_simplesilo_master-7ENH27JSQENY42PFYNEOG3SJGXLTHWJC5Z6KNZUHEDUIGUWU5ZHQ/venv2/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/prod/msp/build/slave1/workspace/Jobs_uiuc_simplesilo_master-7ENH27JSQENY42PFYNEOG3SJGXLTHWJC5Z6KNZUHEDUIGUWU5ZHQ/venv2/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/prod/msp/build/slave1/workspace/Jobs_uiuc_simplesilo_master-7ENH27JSQENY42PFYNEOG3SJGXLTHWJC5Z6KNZUHEDUIGUWU5ZHQ/venv2/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/prod/msp/build/slave1/workspace/Jobs_uiuc_simplesilo_master-7ENH27JSQENY42PFYNEOG3SJGXLTHWJC5Z6KNZUHEDUIGUWU5ZHQ/venv2/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/prod/msp/build/slave1/workspace/Jobs_uiuc_simplesilo_master-7ENH27JSQENY42PFYNEOG3SJGXLTHWJC5Z6KNZUHEDUIGUWU5ZHQ/venv2/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
ImportError: /prod/msp/build/slave1/workspace/Jobs_uiuc_simplesilo_master-7ENH27JSQENY42PFYNEOG3SJGXLTHWJC5Z6KNZUHEDUIGUWU5ZHQ/venv2/lib/python2.7/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so: undefined symbol: PyUnicodeUCS4_FromString
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.
From the last line of error PyUnicodeUCS4_FromString I think this might be because of the wrong UCS type in python. However, I do not have sudo control over the Jenkins agents to install another python version. Any suggestions?
TF version : 1.6.0
Python verson: 2.7.3
I tried running tensorflow inside a Docker image on Jenkins and it worked.

how to install older versions of tensor flow

I am getting headache with tensorflow installations...
I have CUDA 8, CUdnn 6 and UBUNTU 16.04, python 2.7
I want now to install yensorflow. I have followed what they have explained for installation on the website but I have version ismatches of libraries.
As I am using caffe, I do not want to change those versions. So I have to go for older versions of tensorflow it seems.
But I can not find a good way to install it. Every time it is just failuare. I am very tired now.
I go like this:
1- download tensorflow r1.4 from here:
https://github.com/tensorflow/tensorflow/tree/r1.4
2- My 'LD_LIBRARY_PATH' is:
:/usr/local/cuda-8.0/lib64/:/usr/local/cuda/lib64:/home/aa/torch/install/lib:/usr/lib/
3- The I run successfully this:
$ sudo apt-get install python-pip python-dev python-virtualenv # for Python 2.7
4- and this:
$ virtualenv --system-site-packages targetDirectory # for Python 2.7
5- I activate the environment
$ source ~/tensorflow/bin/activate
6- and this
(tensorflow)$ easy_install -U pip
Till here, everything is fine.
7- and when I run this line
pip install --upgrade tensorflow-gpu
It finished successfully with this message:
Successfully installed absl-py-0.1.10 numpy-1.14.1 protobuf-3.5.1 setuptools-38.5.1 six-1.11.0 tensorflow-gpu-1.5.0 tensorflow-tensorboard-1.5.1 werkzeug-0.14.1 wheel-0.30.0
But then I cannot import it in python and this message is given:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/aa/tensorflow/local/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/aa/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/aa/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 74, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/home/aa/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/aa/tensorflow/local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/aa/tensorflow/local/lib/python2.7/site-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.
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.
I think I should go for older versions.
I did install older versions
but then when I test installation in python I see this messages:
>>> import tensorflow
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/aa/.local/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/aa/.local/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 52, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "/home/aa/.local/lib/python2.7/site-packages/tensorflow/core/framework/graph_pb2.py", line 16, in <module>
from tensorflow.core.framework import node_def_pb2 as tensorflow_dot_core_dot_framework_dot_node__def__pb2
File "/home/aa/.local/lib/python2.7/site-packages/tensorflow/core/framework/node_def_pb2.py", line 16, in <module>
from tensorflow.core.framework import attr_value_pb2 as tensorflow_dot_core_dot_framework_dot_attr__value__pb2
File "/home/aa/.local/lib/python2.7/site-packages/tensorflow/core/framework/attr_value_pb2.py", line 16, in <module>
from tensorflow.core.framework import tensor_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__pb2
File "/home/aa/.local/lib/python2.7/site-packages/tensorflow/core/framework/tensor_pb2.py", line 16, in <module>
from tensorflow.core.framework import resource_handle_pb2 as tensorflow_dot_core_dot_framework_dot_resource__handle__pb2
File "/home/aa/.local/lib/python2.7/site-packages/tensorflow/core/framework/resource_handle_pb2.py", line 22, in <module>
serialized_pb=_b('\n/tensorflow/core/framework/resource_handle.proto\x12\ntensorflow\"r\n\x13ResourceHandleProto\x12\x0e\n\x06\x64\x65vice\x18\x01 \x01(\t\x12\x11\n\tcontainer\x18\x02 \x01(\t\x12\x0c\n\x04name\x18\x03 \x01(\t\x12\x11\n\thash_code\x18\x04 \x01(\x04\x12\x17\n\x0fmaybe_type_name\x18\x05 \x01(\tB/\n\x18org.tensorflow.frameworkB\x0eResourceHandleP\x01\xf8\x01\x01\x62\x06proto3')
TypeError: __init__() got an unexpected keyword argument 'syntax'
>>> import tensorflow
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/aa/.local/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/aa/.local/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
ImportError: cannot import name pywrap_tensorflow
You should be able to install earlier versions of tensorflow using
pip install tensorflow==1.3 where 1.3 is the version number. You can pick the version of your choice.
you can find .whl file of tensorflow in here https://pypi.python.org/pypi/tensorflow/1.4.0 and install it using pip.
hope you looking tensorflow 1.4.0 version in case if you want older version change url https://pypi.python.org/pypi/tensorflow/1.x.0(x= version you want)
'The problem is solved.
I had "/usr/lib/python2.7/dist-packages" in my PYTHONPATH.
So there was a version mismatch between protobufs and it was solved by typing 'unset PYTHONPATH' before starting to import tensorflow.

Tensorflow-gpu on windows: ImportError: No module named _pywrap_tensorflow

When I try to import tensorflow I get the following error:
>>import tensorflow
File "C:\Users\...\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import *
File "C:\Users\...\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\__init__.py", line 72, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Users\...\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\__init__.py", line 66, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Users\...\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 21, in <module>
_pywrap_tensorflow = swig_import_helper()
File "C:\Users\...\Anaconda3\envs\tensorflow\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 20, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow')
File "C:\Users\...\Anaconda3\envs\tensorflow\lib\importlib\__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named _pywrap_tensorflow
Failed to load the native TensorFlow runtime.
See https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md#import_error
for some common reasons and solutions. Include the entire stack trace
above this error message when asking for help.
I installed the msvcp140.dll Redistributable as recommended here, but it didn't help. Any ideas? I am running Anaconda3 environment.
It turned out that tensorflow on windows requires python 3.5 or higher while my python was 2.7.8. I found out that this was the problem by the help of this great script which helps trace the source error and gives clear error messages.

Problems with installing tensorf flow on ubuntu

I installed tensorflow on Linux, but when I try to import it in the python shell it cannot find the module. I cannot find the error massage on the tensorflow website. Does anyone have any ideas on how I can fix it?
Whenever I give the command:
import tensorflow as tf
I get as a return:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/beheerder/anaconda2/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "/home/beheerder/anaconda2/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 51, in <module>
from tensorflow.python import pywrap_tensorflow
File "/home/beheerder/anaconda2/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 52, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "/home/beheerder/anaconda2/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "/home/beheerder/anaconda2/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "/home/beheerder/anaconda2/lib/python2.7/site-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.8.0: cannot open shared object file: No such file or directory
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.
Going through your error seems like you're using anaconda for your tensorflow. I have got this error and it seems that tensorflow-gpu for anacoda is still under development and does not work properly.
I suggest you to installed the tensorflow-gpu version out of the anaconda environment. The cpu version works fine though.
After clean installing it again without anacoda for python 2.7. DO:
cd /opt/DL/tensorflow/bin/
source tensorflow-activate
Follow this as it is similar
It looks like it can't find your Cuda library. Things you want to check are:
Do you actually have a GPU? If not: reinstall the non-GPU tensorflow
Do you have Cuda version 8.0? Before you could use an older version, but since the Tensorflow 1.0 release you have to have at least version 8. Maybe reinstall Cuda to fix this problem.
Good luck!

Categories