redhat7.6安装python3 pip3

时间:2020-04-07 19:06:02   收藏:0   阅读:59

安装python

1.安装环境

 yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-develreadline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel sqlite-devel

2.下载包

wget https://www.python.org/ftp/python/3.7.7/Python-3.7.7.tgz

3.解压包

tar -zxvf Python-3.7.7.tgz 

4.创建安装目录,进入解压后的包,制定安装路径进行安装

mkdir -p /usr/local/python3
 
cd Python-3.6.1
 
./configure --prefix=/usr/local/python3
报错:
[root@localhost Python-3.7.7]# ./configure --prefix=/usr/local/python3
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for python3.7... no
checking for python3... no
checking for python... python
checking for --enable-universalsdk... no
checking for --with-universal-archs... no
checking MACHDEP... checking for --without-gcc... no
checking for --with-icc... no
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/root/Python-3.7.7:
configure: error: no acceptable C compiler found in $PATH
See `config.log for more details
因为缺少GCC编译环境:
yum -y install gcc

5.编译安装

make && make install

6.创建软连接

ln -s /usr/local/python3/bin/python3  /usr/bin/python3
ln -s  /usr/local/python3/bin/pip3   /usr/bin/pip3

7、在线升级pip和setuptools

./pip3 install --upgrade setuptools pip

python默认的pip版本和setuptools版本比较旧,如果有网,可以在线更新,下面记录一下离线更新

8.

第7步的升级不成功

手动安装,官网查的安装方法

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

然后到下载目录执行以下命令:

python get-pip.py

9.升级Pip

[root@localhost bin]# pip3 install -U pip
Requirement already up-to-date: pip in /usr/local/python3/lib/python3.7/site-packages (20.0.2)
[root@localhost bin]# which pip3
/usr/bin/pip3

 

原文:https://www.cnblogs.com/shy-1208/p/12655122.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!