我无法为 python 3.7 安装 pip。当我尝试在线搜索时,我找到的一种解决方案是使用 get-pip.py 安装 pip。然而,它对我来说失败了:
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
应该安装包。但是,我验证了该软件包已安装在我的系统上。我不知道我应该如何解决这个问题。有人可以帮忙吗?
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.
更新:
我按照以下步骤安装 Python 3.7https://serverfault.com/questions/918335/best-way-to-run-python-3-7-on-ubuntu-16-04-which-comes-with-python-3-5 https://serverfault.com/questions/918335/best-way-to-run-python-3-7-on-ubuntu-16-04-which-comes-with-python-3-5。另外,当我检查 pip3.7 安装时,我得到的输出为
$ 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
.