简体   繁体   中英

Tensorflow Update Forcing Python3.5 when 3.7 installed

I currently have Tensorflow 1.14.0 installed. I upgraded Python to 3.7 in order to get at least Tensorflow 1.15 if not 2.0. My python updates were successful:

pi@HCoreDEV:~ $ python --version
Python 3.7.0

pi@HCoreDEV:~ $ python3 --version
Python 3.7.0

Now, when I try

sudo pip install --upgrade tensorflow

I get the following (there are a LOT more lines, but they all say "requirement already satisfied" or "up to date"):

Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already up-to-date: tensorflow in /usr/local/lib/python3.5/dist-packages (1.14.0)

NOTE that it defaults to the python 3.5 folder.... ????

BUT: If I try to check the VERSION of TF:

pi@HCoreDEV:~ $ python3 -c 'import tensorflow as tf; print(tf.__version__)'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'tensorflow'

pi@HCoreDEV:~ $ python -c 'import tensorflow as tf; print(tf.__version__)'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'tensorflow'

It doesn't even see ANY TF installed.

Here is my update-alternatives output:

pi@HCoreDEV:~ $ sudo update-alternatives --config python
There are 3 choices for the alternative python (providing /usr/bin/python).

  Selection    Path                Priority   Status
------------------------------------------------------------
  0            /usr/bin/python3.7   3         auto mode
  1            /usr/bin/python2.7   1         manual mode
  2            /usr/bin/python3.5   2         manual mode
* 3            /usr/bin/python3.7   3         manual mode

Press <enter> to keep the current choice[*], or type selection number:

And finally, here is my sourced ~/.bashrc file's aliases for python and python3 for good measure:

alias python='/usr/bin/python3.7'
alias python3='/usr/bin/python3.7'

So WHY is it that with confirmed python3.7 installed and running, Tensorflow only looks at the 3.5 folder, sees an existing install that was running before I upgraded to 3.7, and says the requirements are satisfied?

When I just type "python" into my terminal window, this is the output:

pi@HCoreDEV:~ $ python
Python 3.7.0 (default, Feb  6 2020, 16:11:11) 
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

Lastly, here is my sys.path output:

>>> import sys
>>> sys.path
['', '/usr/local/lib/python37.zip', '/usr/local/lib/python3.7', '/usr/local/lib/python3.7/lib-dynload', '/usr/local/lib/python3.7/site-packages']
>>> 

Need some help, I hope I've provided enough info to make the issue obvious to someone with a bit more experience than me.

The latest Python version on Stretch is 3.5. The command line tool pip calls the Python 3.5 Pip module. If you have another version installed and you want to install/update packages for that specific version, then you must use the correct Pip by running it like this (assuming python3 is the correct version or an alias):

$ python3 -m pip install --upgrade tensorflow

Or if you need sudo :

$ sudo -H python3 -m pip install --upgrade tensorflow

If you don't have Pip installed for that specific Python version you can run:

$ sudo -H python3 -m ensurepip

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM