cannot import name '_pywrap_utils' from 'tensorflow.python' - python

I am working on pose estimation using OpenPose. For that I installed TensorFlow GPU and installed all the requirements including CUDA development kit.
While running the Python script:
C:\Users\abhi\Anaconda3\lib\site-packages\tensorflow\python\ops\resource_variable_ops.py, I encountered the following error:
ImportError: cannot import name '_pywrap_utils' from
'tensorflow.python'
(C:\Users\abhi\Anaconda3\lib\site-packages\tensorflow\python__init__.py)
I tried searching for _pywrap_utils file but there was no such file.

Try pip3 install pywrap and pip3 install tensorflow pywrap utils should be included with tensorflow. If it is not found, that means TF was not installed correctly.

Related

Error running a Python program with sklearn.cluster - "DLL load failed while importing _pairwise_distances_reduction"

I am running Windows 10, and I have Python installed.
When trying to run a Python program with the line from sklearn.cluster import DBSCAN in it, I get the following error:
File "C:\Users\User\AppData\Local\Programs\Python\Python310\lib\site-packages\sklearn\metrics\pairwise.py", line 33, in <module>
from ._pairwise_distances_reduction import PairwiseDistancesArgKmin
ImportError: DLL load failed while importing _pairwise_distances_reduction: The specified module could not be found.
I have tried solving this by entering each of these in the command line (separately, not all at once) and checking whether or the program works:
pip install sklearn
pip install scikit-learn
pip uninstall scipy then pip install scipy
pip uninstall numpy then pip install numpy
I still get the same error when running the program. I'm having difficulty troubleshooting this, searching for "_pairwise_distances_reduction" returns no helpful results.
Is there something I'm supposed to install that I missed?
I was having this problem too, I installed Visual C++ Redistributable Runtimes libraries and it solved my problem.

Can't import object detection imageai (python)

I installed imageai,tensorflow,keras in python with pip
i typed this code
from imageai.Detection import ObjectDetection
it shows this error
ModuleNotFoundError: No module named 'keras.layers.advanced_activations'
module versions
imageai - 2.0.2
keras - 2.90
tensorflow - 2.9.1
im running on windows 10 pro
Try to update version of imageai to new versions.
try this
As imageai now uses Pytorch in backend, you must install a few library dependencies before installing imageai. Please refer to this link for the same.
pip install cython pillow>=7.0.0 numpy>=1.18.1 opencv-python>=4.1.2 torch>=1.9.0 --extra-index-url https://download.pytorch.org/whl/cpu torchvision>=0.10.0 --extra-index-url https://download.pytorch.org/whl/cpu pytest==7.1.3 tqdm==4.64.1 scipy>=1.7.3 matplotlib>=3.4.3 mock==4.0.3
pip install imageai --upgrade
Import the Object detection api from imageai
from imageai.Detection import ObjectDetection
Let us know if the issue still persists. Thank you.

tensorflow_hub import error (most likely due to a circular import) on Mac M1 and Jupyter Notebook

The environments are Mac M1 and miniforge Conda with python3.8. I have completed the following commands to install tensorflow and tensorflow_hub:
conda install -c apple tensorflow-deps
pip install tensorflow-macos
pip install tensorflow-metal
# tried all the conda commands here (https://anaconda.org/conda-forge/tensorflow-hub) and the following
pip install tensorflow_hub
When importing tensorflow_hub on Jupyter Notebook, I got the following error:
cannot import name 'LinearSDCA' from partially initialized module
'tensorflow_estimator.python.estimator.canned.linear' (most likely due to a circular import)
(/myenv/lib/python3.8/site-packages/tensorflow_estimator/python/estimator/canned/linear.py)
When importing tensorflow_hub using the terminal, the error message was:
E tensorflow/core/lib/monitoring/collection_registry.cc:77] Cannot register 2 metrics with the same name: /tensorflow/api/keras/optimizers
...Traceback...
self._metric = self._metric_methods[self._label_length].create(*args)
tensorflow.python.framework.errors_impl.AlreadyExistsError: Another metric with the same name already exists.
Currently, the version of my tensorflow_estimator is 2.6.0, and the one of tensorflow_hub is 0.12.0. I tried changing the version of tensorflow_estimator. However, the only version of tensorflow-macos that I was able to install without an error was 2.6.0, which requires tensorflow_estimator 2.6.0. Appreciate your time and any help you can offer.
Is keras 2.7 installed? If so, please downgrade it via pip install -U keras==2.6.0 since that's not compatible with TF 2.6. TF 2.6.2 fixed the upper bounds for some dependencies so that version should work for you out-of-the-box.

importing tflearn - No module named 'tensorflow.contrib.framework'

then i type import tflearn i got the error below, i follow the guide here: https://www.youtube.com/watch?v=ViO56ASqeks
what can i use tflearn, or shall i use another code?
i got the error below.
import tflearn
File "/usr/local/lib/python3.5/dist-packages/tflearn/__init__.py", line 4, in <module>
from . import config
File "/usr/local/lib/python3.5/dist-packages/tflearn/config.py", line 5, in <module>
from .variables import variable
File "/usr/local/lib/python3.5/dist-packages/tflearn/variables.py", line 7, in <module>
from tensorflow.contrib.framework.python.ops import add_arg_scope as contrib_add_arg_scope
ImportError: No module named 'tensorflow.contrib.framework
can someone help me ?
20/08-2019: Edit 20.35
pip list:
tensorflow 2.0.0rc0
I had a similar problem and I solved it by:-
1) upgrading python to 3.6
2) pip uninstall tflearn
3) pip install git+https://github.com/tflearn/tflearn.git
4) As suggested in another solution tensorflow 2.0.0 does not support tflearn so I installed tensorflow==1.14.0
I found the solution here:-
Issue Link/
If you use an conda environment (and not only, but I advise you to use it), then the solution will be to use a lower version of tensorflow pip uninstall tensorflow pip install tensorflow==1.14.0.
And it is possible to use the script to fix all errors(i used it before downgrade tf):
tf_upgrade_v2 \
--intree my_project/ \
--outtree my_project_v2/ \
--reportfile report.txt
It works for me
You need to have tensorflow installed before you can use tflearn.
From the tflearn github page:
TensorFlow Installation
TFLearn requires Tensorflow (version 1.0+) to be installed.
To install tensorflow:
pip install tensorflow
The tutorial that you are watching uses tensorflow version 0.9 or something, current version is 2.0. The tutorial is 3 years old. You should watch updated video.
However, you can try.
pip install tensorflow==1.0
pip install tflearn
if you're using a virtual environment, make sure you have activated it.
You can use keras instead of tflearn.
tensorflow.contrib is being removed in version 2.0, you therefore need version <= 1.14 to operate tflearn (see here).

Tensorflow import error on Pycharm (Mac)

Error msg (check the screenshot picture please):
ImportError: cannot import name symbol_database
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.
Process finished with exit code 1
Thanks a lot !
I tried to reproduce the problem you're running into using this sample code:
import tensorflow as tf
hello = tf.constant('Hello, Tensorflow!')
But I was not able to. I can run the script without issues within PyCharm and in my command line (exit code 0).
These are the packages (and their version) that are required for tensorflow 0.8.0 to work:
numpy==1.11.0
protobuf==3.0.0b2
six==1.10.0
I'm using PyCharm Community Edition 2016.1.2 and Python 2.7.10 on Mac OS X 10.11.4
How did you install tensorflow?
You should install it via pip (as recommended by the site: https://www.tensorflow.org/versions/r0.8/get_started/os_setup.html#pip-installation)
For Python 2, Mac OS X, this is the installation command:
pip install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.8.0-py2-none-any.whl

Categories

Resources