Numpy API version mismatch - numpy

I'm trying to install tensorflow from source on a Gentoo system (I think I need to do this to get it to use CUDA 9.1).
I'm able to build tensorflow, and then install it as a user with:
pip3 install --no-cache-dir --user /tmp/tensorflow_pkg/tensorflow-1.6.0rc1-cp35-cp35m-linux_x86_64.whl
When I try to import tensorflow I get:
>RuntimeError Traceback (most recent call last)
>RuntimeError: module compiled against API version 0xc but this version of numpy is 0xb
>
>ImportError Traceback (most recent call last)
>ImportError: numpy.core.multiarray failed to import
>
>ImportError Traceback (most recent call last)
>ImportError: numpy.core.umath failed to import
>
>ImportError Traceback (most recent call last)
>ImportError: numpy.core.umath failed to import
So my guess is that tensorflow was built against a different version of numpy than my system default (1.13.3).
The question is how to fix it? There's a lot about this process that's unfamiliar to me, so I would be grateful for any pointers in doing any of the following:
Telling the tensorflow build to use the system-wide numpy. Tensorflow uses bazel for the build process
Figure out what version of numpy tensorflow wants and change my system numpy to that.
Something else??? I can't do much with pip on a system-wide level because pip and Gentoo don't get along. I tried installing via Anaconda but then tensorflow couldn't see my gpus. Installing in a virtualenv with pip (which used to work) didn't work, I think because I've got cuda 9.1 installed. Perhaps I should downgrade to 9.0???
Any help appreciated!

Someone I always figure out how to do something the second after I post on SO! I installed into a virtualenv and did pip3 install --upgrade numpy in the virtualenv. All appears to be well...

Related

ModuleNotFoundError: No module named 'absl'

I followed instructions (https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/training.html) to install the Tensorflow Object Detection API. I use Anaconda on ubuntu18.4 and all of the steps in the instructions seemed to complete OK.
When I train to train my model with the following command:
python model_main_tf2.py --model_dir=models/my_ssd_resnet50_v1_fpn --pipeline_config_path=models/my_ssd_resnet50_v1_fpn/pipeline.config
I get the following error:
Traceback (most recent call last):
File "model_main_tf2.py", line 31, in <module>
from absl import flags
ModuleNotFoundError: No module named 'absl'
I get the error mentioned in the headline. I would be very thankful if someone could help me with a code example to solve the problem.
You need the absl package; to install it, use either one of the following:
pip install absl-py
or if you are in a Conda environment:
conda install -c anaconda absl-py

Tensorflow CPU Version Installation Error

I am running Ubuntu by using Virtualbox on Windows10.
I installed Tensorflow CPU version in terminal using pip3 install --upgrade tensorflow as per instruction given in official site of Tensorflow. And when I tried to validate installation as import tenorflow as tf it showed following error:
Traceback (most recent call last):
File "<stdin>", line1, in <module>
ImportError: No module named tensorflow
What should I do, to fix this error?

Issue while installing Tensorflow

While installing tensorflow(CPU only) I am facing below error :
>>> import tensorflow as tf
Traceback (most recent call last): File "", line 1, in
ImportError: No module named 'tensorflow'
I have python version 3.5
Did you first try:
pip3 install --upgrade tensorflow
It's maybe due to some missing .py files. Download the package from Github link and paste it on python35/Lib/site-packages
import tensorflow as tf
invokes tensorflow not install it there is great article how to install on tensorflow website.
You have not mentioned platform/OS you working on also steps taken if any before trying this command.
best thing for beginners I feel is Anaconda which is suit of packages required for data science.
Give it a try.
python3 -m pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.0-py3-none-any.whl
You can search for the appropriate version you wish to install and update in the above mentioned url.
Try to install an old version of Tensorflow as:
pip install tensorflow==1.5.0
After installing the old version retry with the newest version, for example:
pip install tensorflow==1.9.0

TensorFlow pip installation issue: cannot import name 'descriptor'

I'm seeing the following error when installing TensorFlow:
ImportError: Traceback (most recent call last):
File ".../graph_pb2.py", line 6, in
from google.protobuf import descriptor as _descriptor
ImportError: cannot import name 'descriptor'
This error signals a mismatch between protobuf and TensorFlow versions.
Take the following steps to fix this error:
Uninstall TensorFlow.
Uninstall protobuf (if protobuf is installed).
Reinstall TensorFlow, which will also install the correct protobuf dependency.
I faced the similar issue, after trial and error, I used the below logic to run the program:
pip install --upgrade --no-deps --force-reinstall tensorflow
This will make sure to uninstall and reinstall the program from fresh. It works!
I would be extra careful before uninstalling/reinstalling other packages such as protobuf. What I think would most likely be the issue is difference in versions. As of writing this, the most recent release of python is 3.7 while tensorflow is only compatible up to 3.6.
If you're using a 3rd party distribution like Anaconda, this can get hidden from you. In this case I would recommend creating a new environment in Anaconda, with python 3.6 and then installing tensorflow: https://conda.io/projects/conda/en/latest/user-guide/getting-started.html#managing-python
Try this:
pip uninstall protobuf
brew install protobuf
mkdir -p
/Users/alexeibendebury/Library/Python/2.7/lib/python/site-packages
echo 'import site;
site.addsitedir("/usr/local/lib/python2.7/site-packages")' >>
/Users/alexeibendebury/Library/Python/2.7/lib/python/site-packages/homebrew.pth

Python can't import requests, numpy

I downloaded a Python 3.5 application which needs to import requests, overpy, numpy and tk. So, when I try to import, say, requests, I get:
Traceback (most recent call last): File "", line 1, in
ImportError: No module named 'requests'
I have searched the internet for answers and the best I could find is in this link getting error for importing numpy at Python 3.5.1 . I do have other versions installed, 2.7 is installed by default, however knowing where the problem is doesn't offer a solution.
If it is relevant to configuration issues, I have a Mac with El Capitan.
Do you have pip installed? It's likely that you don't have the package readily available. You will need to download pip for your operating system (if you haven't already), then run
pip install requests
http://docs.python-requests.org/en/master/user/install/
If you have pip installed and think you have requests installed as well, then run
pip freeze
It's most likely not an issue with your python versions, though you will want to be sure when you install pip that it is installed in the correct location.