python3.7 的 pip (Ubuntu 16.04) [英] pip for python3.7 (Ubuntu 16.04)

查看:42
本文介绍了python3.7 的 pip (Ubuntu 16.04)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法为 python 3.7 安装 pip.当我尝试在线搜索时,我发现的一种解决方案是使用 get-pip.py 安装 pip.但是,它对我来说失败了:

I am not able to install pip for python 3.7. When I tried to search online, one solution I found was to install pip using get-pip.py. However, it's failing for me:

sudo python3.7 get-pip.py
Traceback (most recent call last):
  File "get-pip.py", line 21373, in <module>
    main()
  File "get-pip.py", line 197, in main
    bootstrap(tmpdir=tmpdir)
  File "get-pip.py", line 82, in bootstrap
    import pip._internal
  File "/tmp/tmp3273u8va/pip.zip/pip/_internal/__init__.py", line 40, in <module>
  File "/tmp/tmp3273u8va/pip.zip/pip/_internal/cli/autocompletion.py", line 8, in <module>
  File "/tmp/tmp3273u8va/pip.zip/pip/_internal/cli/main_parser.py", line 12, in <module>
  File "/tmp/tmp3273u8va/pip.zip/pip/_internal/commands/__init__.py", line 6, in <module>
  File "/tmp/tmp3273u8va/pip.zip/pip/_internal/commands/completion.py", line 6, in <module>
  File "/tmp/tmp3273u8va/pip.zip/pip/_internal/cli/base_command.py", line 19, in <module>
  File "/tmp/tmp3273u8va/pip.zip/pip/_internal/download.py", line 37, in <module>
  File "/tmp/tmp3273u8va/pip.zip/pip/_internal/utils/glibc.py", line 3, in <module>
  File "/usr/local/lib/python3.7/ctypes/__init__.py", line 7, in <module>
    from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes'

现在,为了解决这个问题,我发现应该安装 libffi-dev 包.但是,我确认该软件包已安装在我的系统上.我不知道我应该如何解决这个问题.有人可以帮忙吗?

Now, to resolve this, I found that libffi-dev package should be installed. However, I verified that this package is already installed on my system. I am not sure how should I resolve this. Can someone please help?

sudo apt-get install libffi-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
libffi-dev is already the newest version (3.2.1-4).
0 upgraded, 0 newly installed, 0 to remove and 50 not upgraded.

更新:我按照以下步骤从 https://serverfault.com/questions/918335/best-way-to-run-python-3-7-on-ubuntu-16-04-which-comes-with-python-3-5.另外,当我检查 pip3.7 安装时,我得到的输出为

Update: I followed the steps to install Python 3.7 from https://serverfault.com/questions/918335/best-way-to-run-python-3-7-on-ubuntu-16-04-which-comes-with-python-3-5. Also, When I check for pip3.7 installation, I am getting the output as

$ pip3.7 --version
pip 19.0.1 from /usr/local/lib/python3.5/dist-packages/pip (python 3.5)
$ sudo apt install python3-pip
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python3-pip is already the newest version (8.1.1-2ubuntu0.4).
0 upgraded, 0 newly installed, 0 to remove and 50 not upgraded.

但是当我执行我的程序时,我得到了一个类似 /usr/local/bin/python3.7: No module named pip 的错误.

But when I execute my program, I get an error like /usr/local/bin/python3.7: No module named pip.

推荐答案

实际上要简单得多.假设您的 Linux 是基于 Debian 的(例如,Ubuntu),您应该根据需要使用 sudo apt install python3-pip 为 Python 3.x 安装 pip,或者使用 sudo apt install python-pip for Python 2.x.

Actually it's a lot simpler. Assuming your Linux is Debian-based (for exaxample, Ubuntu), you should install pip with sudo apt install python3-pip for Python 3.x as you wish, or with sudo apt install python-pip for Python 2.x.

如果您的操作系统不是基于 debian,只需更改正在使用的包管理器(例如使用 yum 或 pacman 而不是 apt).

If your OS is not debian based, just change the package manager in use (for example use yum or pacman instead of apt).

这里,你也可以找到在 Ubuntu 18.04 上安装 pip 的指南.

Here, you can also find a guide for installing pip on Ubuntu 18.04.

希望这会有所帮助!

这篇关于python3.7 的 pip (Ubuntu 16.04)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆