[英]Unable to locate package python-pip Ubuntu 20.04
I am trying to install mininet-wifi.我正在尝试安装 mininet-wifi。 After downloading it, I have been using the following command to install it:
下载后,我一直使用以下命令安装它:
sudo util/install.sh -Wlnfv
However, I keep getting the error:但是,我不断收到错误消息:
E: Unable to locate package python-pip
I have tried multiple times to download python-pip.我曾多次尝试下载 python-pip。 I know mininet-wifi utilizes python 2 instead of python 3. I have tried to download python-pip using the command:
我知道 mininet-wifi 使用 python 2 而不是 python 3。我尝试使用以下命令下载 python-pip:
sudo apt-get install python-pip
But that leads to the same error:但这会导致同样的错误:
E: Unable to locate package python-pip
Pip for Python 2 is not included in the Ubuntu 20.04 repositories. Pip 用于 Python 2 不包含在 Ubuntu 20.04 存储库中。
You need to install pip for Python 2 using the get-pip.py script.您需要使用 get-pip.py 脚本为 Python 2 安装 pip。
1. Start by enabling the universe repository: 1. 首先启用 Universe 存储库:
sudo add-apt-repository universe
2. Update the packages index and install Python 2: 2.更新包索引并安装Python 2:
sudo apt update
sudo apt install python2
3. Use curl to download the get-pip.py script: 3、使用curl下载get-pip.py脚本:
curl https://bootstrap.pypa.io/get-pip.py --output get-pip.py
4. Once the repository is enabled, run the script as sudo user with python2 to install pip: 4. 启用存储库后,以 sudo 用户身份使用 python2 运行脚本以安装 pip:
sudo python2 get-pip.py
If an error occurs, as a fallback, the specific 2.7 version of get-pip.py can be used:如果发生错误,作为后备,可以使用特定的 2.7 版本的 get-pip.py:
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py --output get-pip.py
Pip will be installed globally. Pip 将全局安装。 If you want to install it only for your user, run the command without sudo.
如果您只想为您的用户安装它,请运行不带 sudo 的命令。 The script will also install setuptools and wheel, which allow you to install source distributions
该脚本还将安装 setuptools 和 wheel,它们允许您安装源分发
Verify the installation by printing the pip version number:通过打印 pip 版本号来验证安装:
pip2 --version
The output will look something like this: output 看起来像这样:
pip 20.0.2 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)
Since Python 2 is past its end-of-life, few packages for Python2 are included in 20.04.由于 Python 2 已结束生命周期,因此 20.04 中包含的 Python2 软件包很少。 You have to install
pip
for Python 2 manually:您必须手动为 Python 2 安装
pip
:
First, install Python 2:一、安装Python 2:
sudo apt install python2
Then, follow https://pip.pypa.io/en/stable/installing/ , using python2
:然后,按照https://pip.pypa.io/en/stable/installing/ ,使用
python2
:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python2 get-pip.py
You can run the second step with sudo
.您可以使用
sudo
运行第二步。 If you don't use sudo
, you'll need to change PATH
, as suggested by the installation message.如果您不使用
sudo
,则需要按照安装消息的建议更改PATH
。 Alternatively, and possibly better (since it doesn't change PATH
), use或者,可能更好(因为它不会改变
PATH
),使用
python2 -m pip
whenever you need pip2.每当你需要 pip2。
In my case, the curl command for downloading get-pip.py
gave a syntax error on running sudo python get-pip.py
.就我而言,用于下载
get-pip.py
的 curl 命令在运行sudo python get-pip.py
出现语法错误。
But manual download by visiting https://bootstrap.pypa.io/ and downloading get-pip.py
worked fine for me.但是通过访问https://bootstrap.pypa.io/手动下载并下载
get-pip.py
对我来说效果很好。
I've found that creating a virtualenv
for Python 2.7 installs also pip
我发现为 Python 2.7 创建一个
virtualenv
也会安装pip
$ virtualenv -p python2 venv
$ . venv/bin/activate
$ pip --version
pip 20.0.2 from /home/.../venv/lib/python2.7/site-packages/pip (python 2.7)
Put python3
instead ${PYPKG}
in line 202, and instead python-pip
in line 596 in file install.sh
of mininet-wifi.将
python3
代替${PYPKG}
放在第 202 行,将python-pip
放在 mininet-wifi 的install.sh
文件的第 596 行。
To solve the problem of:解决以下问题:
E: Unable to locate package python-pip
Run the package update index cmd:运行 package 更新索引 cmd:
sudo apt update
If not that, then python-pip-whl
(which is also a package installer) is available in the universe
repository, make sure that's installed and then run:如果不是这样,则可以在
universe
存储库中使用python-pip-whl
(也是 package 安装程序),确保已安装然后运行:
sudo apt-get install python-pip-whl
I specifically needed a Dockerfile file and this is what I have put inside so that it works without errors, I hope it will help someone.我特别需要一个 Dockerfile 文件,这就是我放入的文件,以便它可以正常工作,我希望它会对某人有所帮助。
This is Dockerfile file:这是 Dockerfile 文件:
FROM ubuntu:latest
RUN apt-get update -y
RUN apt-get install -y python3 python3-dev
WORKDIR /app
COPY . /app
ENV DEBUG=True
EXPOSE 80
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.