简体   繁体   English

我有 python3.4 但没有 pip 或 ensurepip .. 我的 python3.4 版本有问题吗?

[英]I have python3.4 but no pip or ensurepip.. is something wrong with my python3.4 version?

I've read in multiple places that python3.4 ships with pip.我在多个地方读到 python3.4 附带 pip。 My OS is Lubuntu 14.04 and the default python version is Python 2.7.6 but in我的操作系统是 Lubuntu 14.04,默认的 Python 版本是 Python 2.7.6 但在

/usr/bin

it says I have python3.4 installed (when I run python3 -V it says I have Python 3.4.0).它说我安装了 python3.4(当我运行 python3 -V 时它说我安装了 Python 3.4.0)。 I made this post earlier last week: How do I use pip 3 with Python 3.4?我上周早些时候发表了这篇文章: 如何在 Python 3.4 中使用 pip 3?

One of the comments to the reply said that "It may be worth mentioning that python3.4 should always ship pip by default. So python3 -m pip should work out of the box. If not, there's python -m ensurepip to bootstrap pip. get-pip.py should not be necessary here."对回复的评论之一说:“可能值得一提的是,python3.4 应该始终默认发送 pip。所以 python3 -m pip 应该开箱即用。如果没有,则有 python -m ensurepip 来引导 pip。 get-pip.py 在这里应该不是必需的。”

I can confirm that I do not have pip because I did我可以确认我没有 pip 因为我有

pip -V

and it said that pip is currently not installed.它说当前没有安装pip。 I tried running我试过跑步

python3 -m pip

and it said它说

/usr/bin/python3: No module named pip

I then tried然后我尝试

python -m ensurepip
python3 -m ensurepip

and it said它说

/usr/bin/python: No module named ensurepip
/usr/bin/python3: No module named ensurepip

With that said, is there something wrong with my version of python3 because it does not have pip or ensurepip?话虽如此,我的python3版本是否有问题,因为它没有pip或ensurepip? I'm asking because I've read in multiple places (for example, in my previous question) that python3.4 comes with pip and I don't think that is true for my case.我问是因为我在多个地方(例如,在我之前的问题中)读到 python3.4 附带 pip,我认为这对我的情况不正确。

My end goal is to run Django1.8 using python 3.4.3.我的最终目标是使用 python 3.4.3 运行 Django1.8。

在 Ubuntu 和其他 Debian 衍生产品上,您必须安装python3-pip才能获得 Python3 的 pip。

apt-get install python3-pip

You can try below code for pip installation on Ubuntu.您可以尝试使用以下代码在 Ubuntu 上安装 pip。

sudo apt update
sudo apt install python3-pip

On Ubuntu Focal/20.04, got the same error在 Ubuntu Focal/20.04 上,得到同样的错误

❯ python3 -m ensurepip --upgrade
/usr/bin/python3: No module named ensurepip

Disable for System Python禁用系统 Python

It looks like it's disable for system python as described by Python2 interpreter output:如 Python2 解释器输出所述,它似乎对系统 python 禁用:

❯ python2 -m ensurepip --upgrade
ensurepip is disabled in Debian/Ubuntu for the system python.

Python modules For the system python are usually handled by dpkg and apt-get.

    apt-get install python-<module name>

Install the python-pip package to use pip itself.  Using pip together
with the system python might have unexpected results for any system installed
module, so use it on your own risk, or make sure to only use it in virtual
environments.

Solution解决方案

Use apt to install it:使用apt安装它:

apt install python3-pip

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM