ZongHan-Li
ZongHan-Li

Reputation: 251

can`t upgrade pip to the newest version 9.0.1 (OS:ubuntu 16.04LTS)

OS: ubuntu 16.04LTS

Python: 2.7.12 + Anaconda2-4.2.0 (64 bit)

I typed pip install --upgrade $TF_BINARY_URL to install tensorflow but terminal showed that my pip verson was 8.1.1, however version 9.0.1 is available.

Then I typed pip install --upgrade pip to upgrade but it showed Requirement already up-to-date: pip in ./anaconda2/lib/python2.7/site-packages,

I still can't use pip version 9.0.1 to install tensorflow. Does anyone know what's going on ??

Upvotes: 25

Views: 85700

Answers (12)

markroxor
markroxor

Reputation: 6476

For me none of the above solutions worked, except
easy_install -U pip

UPDATE: easy_install was part of python-setuptools but from version 39.0.1-2, it is no longer part of it. See changelog.

Upvotes: 17

Gergely M
Gergely M

Reputation: 733

This is not an actual solution, but the output of the commands above, and who knows, maybe useful for some

To sum up what's going on here. The system is a Raspbian 8 Jessie LITE running on a Raspberry Pi 3 meta B, so in short, it's a Debian based Linux OS just like Ubuntu.

On this system the command pip install --upgrade pip doesn't do the job. My thinking is it just simply can't do it because of the required Debian packages which are installed with the sudo apt-get upgrade python-pip command (about 27MB). Pip just simply not allowed to upgrade Debian packages.

I think the source of difference in results for the self-updating command is a minor version difference which doesn't need system level upgrade can be done like that but every other case will require an actual software upgrade, but I may be wrong. Based on my little investigation the correct solution for Debian Linux is:
sudo apt-get upgrade python-pip
or
sudo apt-get upgrade python3-pip
as others stated before.

    pi@lalaland:~ $ pip show pip
    ---
    Name: pip
    Version: 1.5.6
    Location: /usr/lib/python2.7/dist-packages
    Requires: 

    pi@lalaland:~ $ pip3 show pip
    ---
    Name: pip
    Version: 1.5.6
    Location: /usr/lib/python3/dist-packages
    Requires: 

    pi@lalaland:~ $ sudo pip install --upgrade pip
    Downloading/unpacking pip from https://files.pythonhosted.org/packages/0f/74/ecd13431bcc456ed390b44c8a6e917c1820365cbebcb6a8974d1cd045ab4/pip-10.0.1-py2.py3-none-any.whl#sha256=717cdffb2833be8409433a93746744b59505f42146e8d37de6c62b430e25d6d7
      Downloading pip-10.0.1-py2.py3-none-any.whl (1.3MB): 1.3MB downloaded
    Installing collected packages: pip
      Found existing installation: pip 1.5.6
        Not uninstalling pip at /usr/lib/python2.7/dist-packages, owned by OS
    Successfully installed pip
    Cleaning up...

    pi@lalaland:~ $ pip show pip
    ---
    Name: pip
    Version: 1.5.6
    Location: /usr/lib/python2.7/dist-packages
    Requires: 

    pi@lalaland:~ $ pip3 show pip
    ---
    Name: pip
    Version: 1.5.6
    Location: /usr/lib/python3/dist-packages
    Requires: 

    pi@lalaland:~ $ sudo pip3 install --upgrade pip
    Downloading/unpacking pip from https://files.pythonhosted.org/packages/0f/74/ecd13431bcc456ed390b44c8a6e917c1820365cbebcb6a8974d1cd045ab4/pip-10.0.1-py2.py3-none-any.whl#sha256=717cdffb2833be8409433a93746744b59505f42146e8d37de6c62b430e25d6d7
      Downloading pip-10.0.1-py2.py3-none-any.whl (1.3MB): 1.3MB downloaded
    Installing collected packages: pip
      Found existing installation: pip 1.5.6
        Not uninstalling pip at /usr/lib/python3/dist-packages, owned by OS
    Successfully installed pip
    Cleaning up...

    pi@lalaland:~ $ pip show pip
    ---
    Name: pip
    Version: 1.5.6
    Location: /usr/lib/python2.7/dist-packages
    Requires: 

    pi@lalaland:~ $ pip3 show pip
    ---
    Name: pip
    Version: 1.5.6
    Location: /usr/lib/python3/dist-packages
    Requires: 

    pi@lalaland:~ $ pip -version

    Usage:   
      pip <command> [options]

    no such option: -e

    pi@lalaland:~ $ pip --version
    pip 1.5.6 from /usr/lib/python2.7/dist-packages (python 2.7)

    pi@lalaland:~ $ pip3 --version
    pip 1.5.6 from /usr/lib/python3/dist-packages (python 3.4)

The commands seem to have no effect what so ever.
So time to try to upgrade pip with apt-get.

    pi@lalaland:~ $ sudo apt-get upgrade python-pip
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    Calculating upgrade... python-pip is already the newest version.
    Done
    The following packages have been kept back:
      python-openssl python3-openssl
    The following packages will be upgraded:
      curl git git-core git-man gnupg gnupg-agent gnupg2 gpgv libcurl3 libcurl3-gnutls libicu52 libmad0 libperl5.20 libpoppler46
      libprocps3 libsdl-image1.2 libsnmp-base libsnmp30 libssl1.0.0 libvorbis0a libvorbisenc2 libvorbisfile3 openssl perl perl-base
      perl-modules poppler-utils procps wget xdg-utils
    30 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
    Need to get 27.2 MB of archives.
    After this operation, 731 kB of additional disk space will be used.
    Do you want to continue? [Y/n] y
    Get:1 http://mirrordirector.raspbian.org/raspbian/ jessie/main libperl5.20 armhf 5.20.2-3+deb8u11 [1,348 B]
    :
    Get:30 http://mirrordirector.raspbian.org/raspbian/ jessie/main xdg-utils all 1.1.0~rc1+git20111210-7.4+deb8u1 [65.1 kB]             
    Fetched 27.2 MB in 15s (1,767 kB/s)                                                                                                  
    Reading changelogs... Done
    Preconfiguring packages ...
    :
    Setting up xdg-utils (1.1.0~rc1+git20111210-7.4+deb8u1) ...
    Processing triggers for libc-bin (2.19-18+deb8u10) ...

    pi@lalaland:~ $ pip show pip
    ---
    Name: pip
    Version: 1.5.6
    Location: /usr/lib/python2.7/dist-packages
    Requires: 

    pi@lalaland:~ $ pip3 show pip
    ---
    Name: pip
    Version: 1.5.6
    Location: /usr/lib/python3/dist-packages
    Requires: 

    pi@lalaland:~ $ pip --version
    pip 1.5.6 from /usr/lib/python2.7/dist-packages (python 2.7)

    pi@lalaland:~ $ pip3 --version
    pip 1.5.6 from /usr/lib/python3/dist-packages (python 3.4)

    pi@lalaland:~ $ sudo pip install --upgrade pip
    Requirement already up-to-date: pip in /usr/local/lib/python2.7/dist-packages (10.0.1)

    pi@lalaland:~ $ sudo pip3 install --upgrade pip
    Cache entry deserialization failed, entry ignored
    Requirement already up-to-date: pip in /usr/local/lib/python3.4/dist-packages (10.0.1)

at this point pip --version and pip3 --version still returns wrong version numbers.
Although after a soft-reboot (sudo init 6):

    pi@lalaland:~ $ sudo init 6

    pi@lalaland:~ $ pip show pip
    Name: pip
    Version: 10.0.1
    Summary: The PyPA recommended tool for installing Python packages.
    Home-page: https://pip.pypa.io/
    Author: The pip developers
    Author-email: [email protected]
    License: MIT
    Location: /usr/local/lib/python2.7/dist-packages
    Requires: 
    Required-by: 

    pi@lalaland:~ $ pip3 show pip
    Name: pip
    Version: 10.0.1
    Summary: The PyPA recommended tool for installing Python packages.
    Home-page: https://pip.pypa.io/
    Author: The pip developers
    Author-email: [email protected]
    License: MIT
    Location: /usr/local/lib/python3.4/dist-packages
    Requires: 
    Required-by: 

    pi@lalaland:~ $ pip --version
    pip 10.0.1 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)

    pi@lalaland:~ $ pip3 --version
    pip 10.0.1 from /usr/local/lib/python3.4/dist-packages/pip (python 3.4)

All version numbers are fine.

Upvotes: 1

bendaf
bendaf

Reputation: 3031

I removed the pip installed by system package manager

sudo apt-get remove python-pip

than I needed to dwonload it from the dist page

cd ~/Downloads
wget https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py

that solved the problem

Upvotes: 0

mt1022
mt1022

Reputation: 17299

I have the same problem. But my python is under /usr/bin. I tried sudo -H pip install -U pip, which didn't work. However, when I removed the pip installed by system package manager with

sudo apt-get remove python-pip python3-pip

, the problem was solved. It seems that pip installed with system package manager is not consistent with pip wrapped up with python.

Upvotes: 21

cheshirekow
cheshirekow

Reputation: 4907

Unsurprisingly none of the answers here worked for me either. What did work was to go to https://pypi.org/project/pip/9.0.3/#files and download the wheel file. Then I ran pip install --user pip-9.0.3-py2.py3-none-any.whl. That successfully got me to 9.0.3.

After that I did pip install --user --upgrade and it successfully upgraded me to 10.0.0. I suppose I could have directly installed 10.0.0 but I also wanted to double check that there wasn't anything else wrong in the chain.

Anyway, here is where you can download the latest pip: https://pypi.org/project/pip/#files

Upvotes: 1

S0AndS0
S0AndS0

Reputation: 920

If you're only installing things to one user account it is also possible to use pip install --user --upgrade pip avoiding the question of to sudo or not to sudo... just be careful not to use that account with system wide installation of pip goodies.

Upvotes: 3

LF-DevJourney
LF-DevJourney

Reputation: 28529

cannot install pip 9 for python3 on ubuntu16 with pip or pip3

solve by: sudo apt-get upgrade python3-pip (here may be run the apt update first.)
pip3 -V pip 9.0.1 from /home/roofe/.local/lib/python3.5/site-packages (python 3.5)


roofe@utnubu:~$ pip install --upgrade pip Collecting pip Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB) 100% |████████████████████████████████| 1.3MB 14kB/s Installing collected packages: pip Successfully installed pip-9.0.1
note: the upper command only successly installed for python2.

roofe@utnubu:~$ pip3 install --upgrade pip3 Collecting pip3 Could not find a version that satisfies the requirement pip3 (from versions: ) No matching distribution found for pip3 You are using pip version 8.1.1, however version 9.0.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command. roofe@utnubu:~$ pip install --upgrade pip3 Collecting pip3 Could not find a version that satisfies the requirement pip3 (from versions: ) No matching distribution found for pip3 You are using pip version 8.1.1, however version 9.0.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command.

Upvotes: 1

Craig  Hicks
Craig Hicks

Reputation: 2528

First, a discussion of the relationship between python and pip. Then how to apply that to your Anaconda - tensorflow problem.


"Pip" is a python package, meaning it must be run by a python interpreter. The file(s) you see when calling which pip (which pip3) are actually python scripts, and they are effectively aliasing as follows:

  • pip ... results in calling python2.7 -m pip ...

  • pip3 ... results in calling python3.5 -m pip ...

Furthermore, in your environment pip is the alias target of pip2,

Each version of python has it's own search path, so each version finds a different version of the pip package. Moreover,

when the python2.7/sitepackages/pip is called by python2.7, it will install in /home/<user>/.local/lib/python2.7/site-packages (or the window equivalent)

and when the python3.5/site-packages/pip is called by python3.5, it will install in /home/<user>/.local/lib/python3.5/site-packages (or the window equivalent)

It is impossible for python2.7 to call python3.5/.../pip, and impossible for python3.5 to call python2.7/.../pip - so fortunately we don't even have to consider those combinations, whew!

Why did your system not want to upgrade the pip in python2.7/.../site-packages? My guess is that was by design. By the way, are you sure tensorflow is written in python2.7 and not python3.5?


To get back to your question: I found this link which may be of interest to you:

Installing Tensorflow on windows Anaconda2

It appears that the OP was trying to use tensorflow which required python3.5, into Anaconda2 which uses python2.7.

Perhaps you could upgrade to Anaconda3 which uses python3.5? (There might be other ways, but upgrading Anaconda seems klike the one with the least liklihood of cross version problems).

Then you install your tensorflow module with

python3 -m pip install tensorflow

Upvotes: 3

grep
grep

Reputation: 5623

I had same problem BUT because of permission. So simple solution for me:

sudo pip install --upgrade pip

Upvotes: 5

Metagrapher
Metagrapher

Reputation: 8912

sudo -H pip install --upgrade pip

sudo is "super user do". This will allow you to execute commands as a super user. The H flag tells sudo to keep the home directory of the current user. This way when pip installs things, like pip itself, it uses the appropriate directory.

Upvotes: 44

JVSIP
JVSIP

Reputation: 381

I had this same problem. Not sure what is going on. I use both python and python3 and have both a pip and a pip3. By chance I did the following and it seems to have fixed the problem.

pip3 install -U pip

resulting in

Collecting pip
  Using cached pip-9.0.1-py2.py3-none-any.whl
Installing collected packages: pip
Found existing installation: pip 8.1.2
Uninstalling pip-8.1.2:
  Successfully uninstalled pip-8.1.2
Successfully installed pip-9.0.1

Upvotes: 21

Psycho_Coder
Psycho_Coder

Reputation: 245

Try updating pip using conda as follows:

conda update pip

Thereafter try installing tensorflow. See this

Upvotes: 9

Related Questions