0

Please, how can i install Tensorflow in a virtual environment? I have used these commands but it doesn't work..

sudo -H pip3 install tensorflow  --proxy https://XXX.XX.XX.X:3128

sudo -E pip3 install tensorflow  --proxy https://XXX.XX.XX.X:3128

sudo -E pip install tensorflow  --proxy https://XXX.XX.XX.X:3128

sudo -H pip install tensorflow  --proxy https://XXX.XX.XX.X:3128

sudo  pip install tensorflow  --proxy https://XXX.XX.XX.X:3128

It resulted in:

Downloading/unpacking tensorflow
Cannot fetch index base URL https://pypi.python.org/simple/

These are my python and pip versions:

(venv)root@graphene-62:~/tensorflow# pip -V
pip 8.1.2 from /usr/local/lib/python2.7/dist-packages/pip-8.1.2-py2.7.egg
(python 2.7)
(venv)root@graphene-62:~/tensorflow# python -V
Python 2.7.6

After I tried pip install -U tensorflow, I got the following result:

Cannot uninstall 'six'

Then I tried pip install -U tensorflow --ignore-installed six, and with the tf version check I got:

(venv)root@graphene-62:~/tensorflow# python -c "import tensorflow as tf; print(tf.__version__)" 
Illegal instruction (core dumped) (venv)root@graphene-62:~/tensorflow#

Is there another way to download and install Tensorflow?

marcuse
  • 3,389
  • 3
  • 29
  • 50
user1543915
  • 1,025
  • 1
  • 10
  • 16

2 Answers2

1

Please make sure that your pip version is up to date with:

pip install -U pip

Then, as per the comments and edited question, execute:

pip install -U tensorflow==1.5.0 --ignore-installed six

This will ignore the six related error and the slightly downgraded tensorflow package will install and be useable without the Illegal Instruction error.

To check if the installation was successfull, execute:

python -c "import tensorflow as tf; print(tf.__version__)"
marcuse
  • 3,389
  • 3
  • 29
  • 50
  • The first command works fine. With the second command i have: Cannot uninstall 'six'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall. – user1543915 Aug 01 '18 at 09:27
  • >>> import tensorflow as tf Traceback (most recent call last): File "", line 1, in ImportError: No module named tensorflow – user1543915 Aug 01 '18 at 09:27
  • Try `pip install -U tensorflow --ignore-installed six` – marcuse Aug 01 '18 at 09:29
  • in the (venv) (venv)root@graphene-62:~/tensorflow# python -c "import tensorflow as tf; print(tf.__version__)" Illegal instruction (core dumped) (venv)root@graphene-62:~/tensorflow# – user1543915 Aug 01 '18 at 09:33
  • Ah, I think we're almost there. First execute `pip uninstall -U tensorflow` and then `pip install -U tensorflow==1.5.0 --ignore-installed six` – marcuse Aug 01 '18 at 09:37
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/177169/discussion-between-marcuse-and-user1543915). – marcuse Aug 01 '18 at 09:41
  • (venv)root@graphene-62:~/tensorflow# sudo python -c "import tensorflow as tf; print(tf.__version__)" 1.5.0 Thank you so much. – user1543915 Aug 01 '18 at 09:45
  • 1
    Happy to help! Can you mark this question as solved? – marcuse Aug 01 '18 at 09:47
  • Done :) thnks :) – user1543915 Aug 01 '18 at 09:51
0

Recently, pip install tensorflow with python 2.7 might cause the error message:

Could not find a version that satisfies the requirement tensorflow (from versions: ) No matching distribution found for tensorflow

You can instead install TensorFlow with:

pip install -U https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.14.0-cp27-none-linux_x86_64.whl

You can replace the URL of the wheel with some other URLs from https://www.tensorflow.org/install/pip

Same issue with tensorflow-gpu.

Franck Dernoncourt
  • 77,520
  • 72
  • 342
  • 501