【问题标题】:Install pip for python 3.5为 python 3.5 安装 pip
【发布时间】:2016-11-10 00:53:29
【问题描述】:

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

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

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

我在 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

看起来我什至没有为 python 3.5 安装 pip。我该怎么做?

我试过了

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

还有,

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

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

更新

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

@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

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

【问题讨论】:

  • pip already up to date
  • @fwalch 我添加了更新,似乎我缺少各种依赖项——打算尝试重新安装 3.5
  • 那么你能安装python3.5的pip吗?你是怎么做那部分的?这就是问题标题的含义,但您似乎已经这样做了?
  • 你能接受解决方案,回答你自己的问题,然后接受答案吗?这将是回答您自己的问题的认可方式!

标签: python ubuntu installation pip tensorflow


【解决方案1】:

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

您将在那里拥有 Pip 或 easy_install(Python 安装工具的一部分),可用于安装 Pip:

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

或者你可以试试:

python3.5 -m ensurepip

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

sudo apt-get install python3-pip pip3

编辑:尝试此更正以轻松安装:

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

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

另外,python3.5 -m ensurepip 命令缺少这个库:

sudo apt-get install libssl-dev

【讨论】:

  • 在帖子中添加了更新。我开始认为我的 python 3.5 安装在某个地方出错了。我应该重新安装吗?
  • 再次更新,我的python 3.5安装有问题吗?大声笑
  • 我从源代码python.org/downloads 安装虽然现在我想起来了,但我开始认为我安装了错误的源代码(错误的操作系统?)我点击了大的`Download Python 3.5.页面顶部的 21 按钮 -- 我正在运行 linux SCRATCH THIS IDEA
  • easy_install.py 在我的 python 3.5 目录中根本不存在
  • 啊,我发现了问题!我的用户不拥有 pip 目录,我必须使用 -H 标志
【解决方案2】:

试试

sudo add-apt-repository ppa:deadsnakes/ppa

sudo apt update
sudo apt install python3.8 python3.8-dev python3.8-venv

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 2

python3 -V

【讨论】:

  • 问题是找python 3.5版本
【解决方案3】:

所有不同的 Python 3.* 版本似乎都重复使用相同的 pip 位置,这使得调用特定 Python 版本变得困难。

但是,您可以通过将特定版本指定为模块来调用 pip。所以不要这样做:

pip3.5 install <blah>

在大多数发行版中不存在,请执行以下操作:

python3.5 -m pip install <blah>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-03-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-19
    • 2017-07-17
    • 1970-01-01
    相关资源
    最近更新 更多