如何在Ubuntu18上安装Python3.7的pip?

2024-05-16 17:53:35 发布

您现在位置:Python中文网/ 问答频道 /正文

编辑18/02: 因为我仍然没有解决方案,所以我正在更新到目前为止所知道的内容。

我已经成功地安装了Python3.7。 我可以使用pip(或pip3)安装模块,但这些模块安装在Python 3.6(ubuntu附带)中。因此,我无法在Python3.7中导入这些模块(获取未找到的模块) Python 3.7不能识别pip/pip3,所以我不能通过pip/pip3安装 我需要Python3.7

--

我已经在我的Ubuntu 18.04机器上安装了Python 3.7。如果相关,请遵循本说明:

Download : Python 3.7 from Python Website [1] ,on Desktop and manually unzip it, on Desktop Installation : Open Terminal (ctrl +shift+T)

Go to the Extracted folder
$ cd ~/Desktop/Python-3.7.0
$ ./configure
$ make
$ sudo make install

Making Python 3.7 default Python :

$ sudo vim ~/.bashrc
press i
on the last and new line - Type
alias python= python3.7
press Esc
type - to save and exit vim
:wq
now type
$ source ~/.bashrc

From here: https://www.quora.com/How-can-I-upgrade-Python-3-6-to-3-7-in-Ubuntu-18-04

我已经通过pip install module下载了几个模块,但是当我尝试导入它们时,会得到ModuleNotFoundError: No module names 'xx'

所以我做了一些研究,显然当使用pip安装时,它安装在Python以前版本的模块中。 在某个地方(可能是一个问题),我发现了一个使用python3.7 -m pip install module安装模块的建议,但随后我得到了/usr/local/bin/python3.7: no module named pip

现在我陷入困境,pip已经安装,但显然不是针对Python 3.7的。我假设如果我能为Python 3.7安装pip,我就能运行pip install命令并获得所需的模块。 如果是这样的话,既然已经安装了pip for python 3.7,我如何安装它呢?


Tags: 模块installpipandthetomakeon
3条回答

你要找的命令是:

python3.7 -m pip install pip

我也花了很长时间才弄明白。关于它的文件是here

这对我有用。

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

然后使用sudo命令:

python3.7 get-pip.py

基于this instruction

快速添加到mpenkov's answer above(不希望在注释中丢失此内容)

对我来说,我必须先安装pip For 3.6

sudo apt install python3-pip

现在您可以安装Python3.7了

sudo apt install python3.7

然后我可以为3.7安装pip

python3.7 -m pip install pip

另外,在安装其他模块之前

python3.7 -m pip install <module>

编辑:

我知道这对大多数人来说是显而易见的。但是如果你想要python 3.8,就用python3.8代替python3.7

相关问题 更多 >