为 python 3.5 安装 pip

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38249961/
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 20:33:42  来源:igfitidea点击:

Install pip for python 3.5

pythonubuntuinstallationpiptensorflow

提问by Kendall Weihe

SOLUTIONMy user did not own permissions to the pip directory, I reinstalled Python 3.5 using the sudo -Hflag

解决方案我的用户没有 pip 目录的权限,我使用该sudo -H标志重新安装了 Python 3.5

I'm trying to install Tensorflow for python 3.5 using pip3 -- for reasons described in thisgithub issue -- but when I install using sudo pip3 install *.whlit installs to python 3.4.

我正在尝试使用 pip3 为 python 3.5 安装 Tensorflow——出于这个github 问题中描述的原因——但是当我使用sudo pip3 install *.whl它安装到 python 3.4 时。

How can I redirect pip3to install into my python 3.5 directory?

如何重定向pip3以安装到我的 python 3.5 目录中?

I'm running on Ubuntu 14.04

我在 Ubuntu 14.04 上运行

kendall@kendall-Macmini:~/Downloads$ python3.4 -m pip --version
pip 8.1.2 from /usr/local/lib/python3.4/dist-packages/pip-8.1.2-py3.4.egg (python 3.4)
kendall@kendall-Macmini:~/Downloads$ python3.5 -m pip --version
/usr/local/bin/python3.5: No module named pip

It looks like I don't even have pip installed for python 3.5. How can I do this?

看起来我什至没有为python 3.5安装pip。我怎样才能做到这一点?

I've tried

我试过了

kendall@kendall-Macmini:~/Downloads$ pip install -U pip
Requirement already up-to-date: pip in /usr/local/lib/python3.4/dist-packages/pip-8.1.2-py3.4.egg

Also,

还,

kendall@kendall-Macmini:~/Downloads$ whereis pip
pip: /usr/bin/pip /usr/bin/X11/pip /usr/local/bin/pip3.4 /usr/local/bin/pip /usr/local/bin/pip2.7 /usr/share/man/man1/pip.1.gz

I can't find any support for upgrading to pip3.5

我找不到升级到 pip3.5 的任何支持

UPDATE

更新

kendall@kendall-Macmini:~/Downloads$ sudo apt-get install python3-setuptools
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python3-setuptools is already the newest version.
The following packages were automatically installed and are no longer required:
  libntdb1 linux-headers-4.2.0-27 linux-headers-4.2.0-27-generic
  linux-image-4.2.0-27-generic linux-image-extra-4.2.0-27-generic
  linux-signed-image-4.2.0-27-generic python-ntdb
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
kendall@kendall-Macmini:~/Downloads$ sudo python3.5 easy_install.py pip
python3.5: can't open file 'easy_install.py': [Errno 2] No such file or directory
kendall@kendall-Macmini:~/Downloads$ python3.5 -m ensurepip
Ignoring ensurepip failure: pip 8.1.1 requires SSL/TLS
kendall@kendall-Macmini:~/Downloads$ sudo apt-get install pip3
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package pip3


kendall@kendall-Macmini:~/Downloads$ sudo apt-get install libssl-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
libssl-dev is already the newest version.
The following packages were automatically installed and are no longer required:
  libntdb1 linux-headers-4.2.0-27 linux-headers-4.2.0-27-generic
  linux-image-4.2.0-27-generic linux-image-extra-4.2.0-27-generic
  linux-signed-image-4.2.0-27-generic python-ntdb
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
kendall@kendall-Macmini:~/Downloads$ python3.5 -m ensurepip
Ignoring ensurepip failure: pip 8.1.1 requires SSL/TLS

As recommended by @fwalsh

正如@fwalsh 推荐的那样

kendall@kendall-Macmini:~/Downloads$ python3.5 get-pip.py 
Traceback (most recent call last):
  File "get-pip.py", line 19177, in <module>
    main()
  File "get-pip.py", line 194, in main
    bootstrap(tmpdir=tmpdir)
  File "get-pip.py", line 82, in bootstrap
    import pip
zipimport.ZipImportError: can't decompress data; zlib not available

It seems like I'm missing all sorts of dependencies -- I'm going to try reinstalling

似乎我缺少各种依赖项——我要尝试重新安装

回答by L Martin

Check: /usr/local/lib/python3.5/dist-packages

检查:/usr/local/lib/python3.5/dist-packages

You'll either have Pip there or easy_install(part of Pythons setup tools), which can be used to install Pip:

你要么有 Pip 要么有 easy_install(Pythons 安装工具的一部分),它可以用来安装 Pip:

sudo apt-get install python3-setuptools
sudo python3.5 easy_install.py pip

Or you can try:

或者你可以试试:

python3.5 -m ensurepip

Another option is attempting to install from a repository, the package name depends on your distribution:

另一种选择是尝试从存储库安装,包名称取决于您的发行版:

sudo apt-get install python3-pip pip3

Edit:Try this correction for easy install:

编辑:尝试此更正以方便安装:

sudo apt-get install python3-setuptools
sudo python3.5 /usr/local/lib/python3.5/dist-packages/easy_install.py pip

I'm assuming that's the directory it's installed to.

我假设这是它安装到的目录。

Also, you're missing this library for the python3.5 -m ensurepipcommand:

此外,您缺少该python3.5 -m ensurepip命令的库:

sudo apt-get install libssl-dev