Importing Tensorflow giving weird errors - python

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.

Related

Facing error messages when importing sklearn in python i.d

I get an error when importing sklearn in python 3.9.
I am using I.D.L.E. in Windows.
Installed it using cmd command: pip install -U scikit-learn as given in https://scikit-learn.org/stable/install.html
The received error message is:
Traceback (most recent call last):
File "<pyshell#9>", line 1, in <module>
import sklearn
File "C:\Users\USER\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\__init__.py", line 82, in <module>
from .base import clone
File "C:\Users\USER\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\base.py", line 17, in <module>
from .utils import _IS_32BIT
File "C:\Users\USER\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\utils\__init__.py", line 29, in <module>
from .fixes import parse_version, threadpool_info
File "C:\Users\USER\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\utils\fixes.py", line 19, in <module>
import scipy.stats
File "C:\Users\USER\AppData\Local\Programs\Python\Python39\lib\site-packages\scipy\stats\__init__.py", line 453, in <module>
from ._stats_py import *
File "C:\Users\USER\AppData\Local\Programs\Python\Python39\lib\site-packages\scipy\stats\_stats_py.py", line 38, in <module>
from scipy.spatial.distance import cdist
File "C:\Users\USER\AppData\Local\Programs\Python\Python39\lib\site-packages\scipy\spatial\__init__.py", line 104, in <module>
from ._qhull import *
ImportError: DLL load failed while importing _qhull: The specified module could not be found.
Please help.
Since the required file _qhull.yp39-win_amd64.pyd is there, it must be a problem with the dependencies this DLL file has and can't find on your computer.
Use a dependency walker like this one to find out what is missing on your system and see that you get those missing pieces installed.
Quite likely you are missing some of the Microsoft Redistributable Visual Studio Files.
Apparently my scipy got corrupted somehow. Uninstalling and re-installing it fixed the problem. Thanks everyone who took their time and effort to help though.

Rasa init gives an error "Failed to load the native TensorFlow runtime"

I tried different versions of TF, installed VisualStudio but it never worked.
I'm using Python 3.8.0rc1 on windows 10 64-bit.
Would highly appreciate your help!
C:\WINDOWS\system32>rasa init
Traceback (most recent call last):
File "c:\users\наталия\appdata\local\programs\python\python38\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: A dynamic link library (DLL) initialization routine failed.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\users\наталия\appdata\local\programs\python\python38\lib\runpy.py", line 192, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\users\наталия\appdata\local\programs\python\python38\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\Наталия\AppData\Local\Programs\Python\Python38\Scripts\rasa.exe\__main__.py", line 7, in <module>
File "c:\users\наталия\appdata\local\programs\python\python38\lib\site-packages\rasa\__main__.py", line 104, in main
set_log_level(log_level)
File "c:\users\наталия\appdata\local\programs\python\python38\lib\site-packages\rasa\utils\common.py", line 66, in set_log_level
update_tensorflow_log_level()
File "c:\users\наталия\appdata\local\programs\python\python38\lib\site-packages\rasa\utils\common.py", line 108, in update_tensorflow_log_level
import tensorflow as tf
File "c:\users\наталия\appdata\local\programs\python\python38\lib\site-packages\tensorflow\__init__.py", line 41, in <module>
from tensorflow.python.tools import module_util as _module_util
File "c:\users\наталия\appdata\local\programs\python\python38\lib\site-packages\tensorflow\python\__init__.py", line 40, in <module>
from tensorflow.python.eager import context
File "c:\users\наталия\appdata\local\programs\python\python38\lib\site-packages\tensorflow\python\eager\context.py", line 35, in <module>
from tensorflow.python import pywrap_tfe
File "c:\users\наталия\appdata\local\programs\python\python38\lib\site-packages\tensorflow\python\pywrap_tfe.py", line 28, in <module>
from tensorflow.python import pywrap_tensorflow
File "c:\users\наталия\appdata\local\programs\python\python38\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 83, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "c:\users\наталия\appdata\local\programs\python\python38\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 64, in <module>
from tensorflow.python._pywrap_tensorflow_internal import *
ImportError: DLL load failed while importing _pywrap_tensorflow_internal: A dynamic link library (DLL) initialization routine failed.
Failed to load the native TensorFlow runtime.
First of all, I will suggest to use the Linux, i.e. Ubuntu Operating System through VM.
Also which ever version you use for the Rasa or the VM or Python or Anaconda Environment, always opt for stable version.
Refer Rasa Change logs https://legacy-docs-v1.rasa.com/changelog/
also follow the Installation guide where the python versions are mentioned:
https://legacy-docs-v1.rasa.com/user-guide/installation/
As you see 3.8 python version is not mentioned, so read the document and install as per the instruction, this could be a possibility for that error
Problem solved!
So after having read multiple issues similar to mine that other people had I figured that the main problem is my old Pentium CPU which doesn't support AVX instructions.
I tried older versions of tensorflow and rasa which didn't require AVX (tensorflow 1.15 and earlier, rasa 1.7.4 and earlier) but always received dependencies errors.
So I ended up upgrading my Pentium CPU for Core i-7 3770 and now it all works just fine in the latest versions available.
When I faced the similar error, I uninstalled Tensorflw completely, cleaned cache and then installed it again with Conda.
Previously I had tensorflow installed using pip.

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.

Error importing tensorflow in simple python code with import

I am trying to run sample code in tensor flow with only one line - import tensorflow as tf. But it gives this error.
Traceback (most recent call last): File "sample.py", line 1, in <module>
import tensorflow as tf File "/home/djlimdiwala/.local/lib/python2.7/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import * File "/home/djlimdiwala/.local/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 72, in <module>
raise ImportError(msg) ImportError: Traceback (most recent call last): File "/home/djlimdiwala/.local/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 61, in <module>
from tensorflow.python import pywrap_tensorflow File "/home/djlimdiwala/.local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
_pywrap_tensorflow = swig_import_helper() File "/home/djlimdiwala/.local/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
_mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description) ImportError: libcudart.so.8.0: cannot open shared object file: No such file or directory
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.
CAN ANYONE HELP IN THIS?
Focus on this part:
"ImportError: libcudart.so.8.0: cannot open shared object file: No such file or directory"
The reason why this message is displayed because Tensorflow couldn't find the place where the Nvidia cuda library is installed. Try to install it properly along with the tensorflow.
If you are using the pre-built TensorFlow binaries(included in their website https://www.tensorflow.org/install/install_linux) then please check the supported cuda and cudnn versions before installing. Those pre-built TensorFlow versions support specific versions only.
It is giving you this error because some how when you install cuda, it does not save its location in the environment.
ImportError: libcudart.so.8.0: cannot open shared object file: No such file or directory
Export the path to cuda lib:
sudo ldconfig /usr/local/cuda/lib64
cuda_version: 8.0
cuDNN_version: 5.1

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

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).

Categories