error when importing tensorflow in python on windows

  • Last Update :
  • Techknowledgy :

At first, I used an anaconda environment with Python 3.5 and PIP version 19 but had the same problem. so instead of PIP, I used Conda package manager:

conda install TensorFlow

If you have a GPU in your system and it is conflicting with the current set of libraries or throwing a cudnn error then you can add the following line in your code to disable the GPU

os.environ["CUDA_VISIBLE_DEVICES"] = "-1"

Suggestion : 2

Last updated 2022-02-17 UTC.

Unzipping simple_console_for_windows.zip to create runfiles tree...[. / bazel - bin / tensorflow / tools / pip_package / simple_console_for_windows.zip]
End - of - central - directory signature not found.Either this file is not
a zipfile, or it constitutes one disk of a multi - part archive.In the
latter
case the central directory and zipfile comment will be found on
the last disk(s) of this archive.
unzip: cannot find zipfile directory in one of . / bazel - bin / tensorflow / tools / pip_package / simple_console_for_windows.zip or
   . / bazel - bin / tensorflow / tools / pip_package / simple_console_for_windows.zip.zip, and cannot find. / bazel - bin / tensorflow / tools / pip_package / simple_console_for_windows.zip.ZIP, period.
ImportError: libcudart.so.Version: cannot open shared object file:
   No such file or directory
ImportError: libcudnn.Version: cannot open shared object file:
   No such file or directory
libprotobuf ERROR google / protobuf / src / google / protobuf / io / coded_stream.cc: 207] A
protocol message was rejected because it was too big(more than 67108864 bytes).
To increase the limit(or to disable these warnings), see

CodedInputStream::SetTotalBytesLimit() in google / protobuf / io / coded_stream.h.
Error importing tensorflow.Unless you are using bazel, you should
not
try to
import tensorflow from its source directory;
please exit the
tensorflow source tree, and relaunch your python interpreter from
there.
IOError: [Errno 2] No such file or directory:
   '/tmp/pip-o6Tpui-build/setup.py'

Suggestion : 3

I'm new at python (version of python 3.7.7) and I'm trying to run a finished project, I imported everything but tensorflow is not working the error is shown down below:,It happenedย to me as well. I tried multiple ways to install Tensorflow in my own system. But it shows me a similar type of error. It most probably to the environment-related. You can give it one more try. Just uninstall python and TensorFlow and related packages. And try with another version., tensorflow is installed but theres an error while... ,100265/tensorflow-is-installed-but-theres-an-error-while-importing

I'm new at python (version of python 3.7.7) and I'm trying to run a finished project, I imported everything but tensorflow is not working the error is shown down below:

Traceback (most recent call last): File
"C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow.py",
line 64, in <module>
   from tensorflow.python._pywrap_tensorflow_internal import * ImportError: DLL load failed: 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/User/Desktop/adsp/train.py", line 1, in <module>
      import tensorflow as tf File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\__init__.py",
      line 41, in <module>
         from tensorflow.python.tools import module_util as _module_util File
         "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\__init__.py",
         line 39, in <module>
            from tensorflow.python import pywrap_tensorflow as _pywrap_tensorflow File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow.py",
            line 83, in <module>
               raise ImportError(msg) ImportError: Traceback (most recent call last): File
               "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow\python\pywrap_tensorflow.py",
               line 64, in <module>
                  from tensorflow.python._pywrap_tensorflow_internal import * ImportError: DLL load failed: A dynamic link library (DLL)
                  initialization routine failed. 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.
  • Create one environment and install latest version of python.

$ conda create - n tensorflow pip python = 3.6
  • Use tensorflow environment.

$ activate tensorflow
  • Install tensorflow.

$ pip install--ignore - installed--upgrade tensorflow == 1.9
  • Uninstall the current version of Tensorflow.

$ pip uninstall tensorflow
  • Reinstall tensorflow 1.15
$ pip install tensorflow == 1.15

I tried the following commands it didn't work :

pip uninstall tensorflow
pip uninstall tensorflow 
pip install tensorflow == 1.15

Suggestion : 4

Last updated: Apr 18, 2022

Copied!#๐Ÿ‘‡๏ธ Requires the latest pip
pip install--upgrade pip

#๐Ÿ‘‡๏ธ in a virtual environment or using Python 2
pip install tensorflow

#๐Ÿ‘‡๏ธ
for python 3(could also be pip3 .10 depending on your version)
pip3 install tensorflow

#๐Ÿ‘‡๏ธ
if you get permissions error
sudo pip3 install tensorflow

#๐Ÿ‘‡๏ธ
if you don 't have pip in your PATH environment variable
python - m pip install tensorflow

#๐Ÿ‘‡๏ธ
for python 3(could also be pip3 .10 depending on your version)
python3 - m pip install tensorflow

#๐Ÿ‘‡๏ธ
for Anaconda
conda install - c conda - forge tensorflow
Copied!
   import tensorflow as tf

dataset1 = tf.data.Dataset.from_tensor_slices(tf.random.uniform([4, 10]))

print(dataset1.element_spec)
Copied!python--version
Copied!pip3 .10 install tensorflow

#๐Ÿ‘‡๏ธ
if you get permissions error use pip3(NOT pip3.X)
sudo pip3 install tensorflow
Copied!#๐Ÿ‘‡๏ธ make sure to use your version of Python, e.g.3.10
python3 - m pip install tensorflow
Copied!#๐Ÿ‘‡๏ธ check
if you have tensorflow installed
pip3 show tensorflow

#๐Ÿ‘‡๏ธ
if you don 't have pip setup in PATH
python3 - m pip show tensorflow