简体   繁体   English

如何在 CentOS 7 上专门为 Python3 安装 pip?

[英]How to install pip specifically for Python3 on CentOS 7?

CentOS 7 already has Python2.7.5 stock installed. CentOS 7 已经安装了 Python2.7.5 股票。 I am doing an online course that requires Python3.x installed.我正在做一个需要安装 Python3.x 的在线课程。 So these are the following steps i took to install Python3.7.3.rc1 :所以这些是我安装 Python3.7.3.rc1 所采取的以下步骤:

$cd /usr/src
$sudo wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3rc1.tgz
$sudo tar xzf Python-3.7.3rc1.tgz
$cd Python-3.7.3rc1
$sudo ./configure --enable-optimizations
$sudo make altinstall
$sudo rm /usr/src/Python-3.7.3rc1.tgz
$python3.7 --version
Python 3.7.3rc1

I followed these steps religiously from this link : https://tecadmin.net/install-python-3-7-on-centos/我从这个链接虔诚地遵循这些步骤: https : //tecadmin.net/install-python-3-7-on-centos/

During my course i was required to install pyperclip using pip.在我的课程中,我需要使用 pip 安装 pyperclip。 So i did :所以我做了 :

$python3.7 -m pip install pyperclip
/usr/local/bin/python3.7: No module named pip

Please suggest a method to install pip for Python3.7.3rc1.请提出一种为Python3.7.3rc1安装pip的方法。

You should have taken the default available python3, that is the python3.6 package in centos7 that would have been easier to setup rather than compile an unsupported version.您应该采用默认可用的python3,即centos7 中的python3.6 包,它比编译不受支持的版本更容易设置。 Suggest you install the supported python3 package in centos建议你在centos中安装支持的python3包

Try doing yum install python36 from repository尝试从存储库执行 yum install python36

sudo yum install -y https://repo.ius.io/ius-release-el7.rpm

Update yum package更新 yum 包

 sudo yum update

Install python36 along with pip安装 python36 和 pip

sudo yum install -y python36u python36u-libs python36u-devel python36u-pip

Below steps are for python3.7 , suggest avoiding unsupported packages.下面的步骤是针对 python3.7 的,建议避免不支持的包。 Alternate Steps for pip setup for Centos You need to install pip for python3.7 series Step 1: First install the EPEL Repository Centos pip 设置的替代步骤您需要为 python3.7 系列安装 pip 步骤 1:首先安装 EPEL 存储库

sudo yum install epel-release

Step 2: Installing pip第二步:安装pip

python37 -m pip

Step 3: Verify if pip was installed properly pip --version第 3 步:验证 pip 是否正确安装 pip --version

If the command not found error shows up, try如果出现命令未找到错误,请尝试

python37 -m ensurepip

I also as you said "followed these steps religiously from this link: https://tecadmin.net/install-python-3-7-on-centos/ ."我也正如你所说的“从这个链接虔诚地遵循这些步骤: https : //tecadmin.net/install-python-3-7-on-centos/”

It was not an option for me to install python3.6, as I explicitly needed 3.7.安装 python3.6 不是我的选择,因为我明确需要 3.7。 I was able to install using the following procedure:我能够使用以下过程进行安装:

# AFAIK, libffi-devel solved the "ModuleNotFoundError: No module named '_ctypes'" I had when I tried installing without it. 
yum install libffi-devel 

cd /usr/src
wget https://www.python.org/ftp/python/3.7.5/Python-3.7.5.tgz
tar xzf Python-3.7.5.tgz
cd Python-3.7.5
./configure --enable-optimizations
make install  # Or: make altinstall
python3 -V
pip3 --version
rm -f /usr/src/Python-3.7.5.tgz

What I changed from the referenced article is the version (3.7.5 instead of 3.7.4) and in addition installed "libffi-devel".我从引用的文章中更改的是版本(3.7.5 而不是 3.7.4),此外还安装了“libffi-devel”。 It could be that this one would have solved on 3.7.4 as well.可能这个问题也可以在 3.7.4 上解决。

For CentOS 6 and 7 you can run this:对于 CentOS 6 和 7,您可以运行:

sudo yum install python37-setuptools sudo easy_install-3.7 pip

Edit: You should then be able to install using pip3 install <package>编辑:然后您应该能够使用pip3 install <package>进行pip3 install <package>

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

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