Python 无法将 pip 升级到最新版本 9.0.1 (OS:ubuntu 16.04LTS)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40485380/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 23:35:43  来源:igfitidea点击:

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

pythonubuntupip

提问by ZongHan-Li

OS:ubuntu 16.04LTS

操作系统:ubuntu 16.04LTS

Python:2.7.12 + Anaconda2-4.2.0 (64 bit)

Python:2.7.12 + Anaconda2-4.2.0 (64 bit)

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

我输入pip install --upgrade $TF_BINARY_URL要安装 tensorflow 但终端显示我的 pip8.1.1版本9.0.1是,但是版本可用。

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

然后我输入pip install --upgrade pip升级但它显示 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 ??

我仍然无法使用 pip 9.0.1 版安装 tensorflow。有谁知道这是怎么回事??

回答by Metagrapher

sudo -H pip install --upgrade pip

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.

sudo 是“超级用户做”。这将允许您以超级用户身份执行命令。H 标志告诉 sudo 保留当前用户的主目录。这样当 pip 安装东西时,比如 pip 本身,它会使用适当的目录。

回答by mt1022

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

我也有同样的问题。但我python的在/usr/bin. 我试过了sudo -H pip install -U pip,没有用。但是,当我删除了pip由系统包管理器安装的

sudo apt-get remove python-pip python3-pip

, the problem was solved. It seems that pipinstalled with system package manager is not consistent with pipwrapped up with python.

,问题就解决了。似乎pip用系统包管理器安装与pippython.

回答by JVSIP

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.

我有同样的问题。不知道发生了什么。我同时使用 python 和 python3,并且有一个 pip 和一个 pip3。碰巧我做了以下事情,它似乎已经解决了这个问题。

pip3 install -U pip

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

回答by markroxor

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

对我来说,上述解决方案都不起作用,除了
easy_install -U pip

UPDATE: easy_installwas part of python-setuptoolsbut from version 39.0.1-2, it is no longer part of it. See changelog.

更新: easy_install是一部分,python-setuptools但从 version 开始39.0.1-2,它不再是它的一部分。请参阅变更日志

回答by Psycho_Coder

Try updating pip using conda as follows:

尝试使用 conda 更新 pip,如下所示:

conda update pip

conda update pip

Thereafter try installing tensorflow. See this

此后尝试安装 tensorflow。看到这个

回答by grep

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

由于许可,我遇到了同样的问题。对我来说如此简单的解决方案:

sudo pip install --upgrade pip

回答by Craig Hicks

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

首先讨论python和pip的关系。然后如何将其应用于您的 Anaconda - 张量流问题。



"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”是一个 python 包,意味着它必须由 python 解释器运行。您在调用which pip( which pip3)时看到的文件实际上是 python 脚本,它们有效地别名如下:

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

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

  • pip ...结果在调用 python2.7 -m pip ...

  • pip3 ...结果在调用 python3.5 -m pip ...

Furthermore, in your environment pipis the alias target of pip2,

此外,在您的环境中pip是别名目标pip2

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

每个版本的python都有自己的搜索路径,所以每个版本都会找到不同版本的pip包。而且,

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

python2.7/sitepackages/pip被调用时python2.7,它将安装在 /home/<user>/.local/lib/python2.7/site-packages(或等效的窗口中)

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

并且当python3.5/site-packages/pip被调用时python3.5,它将安装在 /home/<user>/.local/lib/python3.5/site-packages(或等效的窗口中)

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

不可能python2.7调用python3.5/.../pip,也不可能python3.5调用python2.7/.../pip- 所以幸运的是我们甚至不必考虑这些组合,哇!

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

为什么你的系统不想升级pipin python2.7/.../site-packages?我的猜测是设计使然。顺便说一句,你确定tensorflow是写在python2.7而不是python3.5



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

回到您的问题:我找到了您可能感兴趣的链接:

Installing Tensorflow on windows Anaconda2

在 windows Anaconda2 上安装 Tensorflow

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

看来 OP 正试图将需要 python3.5 的 tensorflow 用于使用 python2.7 的 Anaconda2。

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).

也许您可以升级到使用 python3.5 的 Anaconda3?(可能还有其他方法,但升级 Anaconda 似乎是最不可能出现跨版本问题的方法)。

Then you install your tensorflow module with

然后你安装你的tensorflow模块

python3 -m pip install tensorflow

python3 -m pip install tensorflow

回答by S0AndS0

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

如果您只将东西安装到一个用户帐户,也可以使用pip install --user --upgrade pip避免使用sudo或不使用的问题sudo......只是要小心不要在系统范围内安装pip好东西时使用该帐户。

回答by cheshirekow

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/#filesand 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.

不出所料,这里的所有答案都不适合我。什么工作是去https://pypi.org/project/pip/9.0.3/#files并下载轮文件。然后我跑了pip install --user pip-9.0.3-py2.py3-none-any.whl。这成功地让我到了9.0.3

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

在那之后,我做到了pip install --user --upgrade,它成功地将我升级到10.0.0. 我想我可以直接安装,10.0.0但我也想仔细检查链中没有任何其他错误。

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

无论如何,您可以在这里下载最新的 pip:https: //pypi.org/project/pip/#files

回答by Gergely M

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.

总结一下这里发生的事情。该系统是在 Raspberry Pi 3 meta B 上运行的 Raspbian 8 Jessie LITE,所以简而言之,它是一个基于 Debian 的 Linux 操作系统,就像 Ubuntu 一样。

On this system the command pip install --upgrade pipdoesn'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-pipcommand (about 27MB). Pip just simply not allowed to upgrade Debian packages.

在这个系统上,命令pip install --upgrade pip不能完成这项工作。我的想法是它根本无法做到,因为需要使用sudo apt-get upgrade python-pip命令安装的 Debian 软件包(大约 27MB)。Pip 只是不允许升级 Debian 软件包。

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.

我认为自我更新命令结果差异的根源是一个小的版本差异,不需要系统级升级可以这样做,但其他所有情况都需要实际的软件升级,但我可能是错的。根据我的小调查,Debian Linux 的正确解决方案是: 或者 正如其他人之前所说的那样。
sudo apt-get upgrade python-pip

sudo apt-get upgrade python3-pip

    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 pipwith apt-get.

这些命令似乎没有任何效果。
所以是时候尝试pip使用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 --versionand pip3 --versionstill returns wrong version numbers.
Although after a soft-reboot (sudo init 6):

在这一点上pip --version,并pip3 --version仍返回错误的版本号。
虽然在软重启 ( 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.

所有版本号都很好。