redhat7安装python3.6.4、settools、和pip3

本文详细介绍了如何从源码编译安装Python3.6.4,包括下载、解压、编译、安装及配置软链接等步骤。同时,还提供了安装setuptools和pip3的方法,并解决可能遇到的错误,如压缩模块缺失和HTTPSHandler导入问题。
安装python3.6.4
  1. 下载python
wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tar.xz
  1. 解压
tar -zxvf /root/python-3.6.4.tar.xz
  1. 编译安装
cd python-3.6.4
make && make install
  1. 建立软链接
[root@localhost ~]# ln -sf /usr/bin/python2.7 /usr/bin/python
[root@localhost ~]# ln -s /usr/local/python3.6 /usr/bin/python3
  1. 测试
python -V
Python 3.6.4   #结果显示
安装setuptools
  1. 下载
wget –no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-19.6.tar.gz#md5=c607dd118eae682c44ed146367a17e26
  1. 解压
tar -zxvf setuptools-19.6.tar.gz
  1. 编译安装
cd setuptools-19.6.tar.gz

python3 setup.py build

python3 setup.py install

如果报错Compression requires the (missing) zlib module.
安装缺少的模块

yum -y install zlib
yum -y install zlib-devel

安装完成后进入Python-3.6.4目录,再一次编译安装python

cd /root/Python-3.6.4
make && make install

在进入setuptools-19.6目录

cd /root/setuptools-19.6
python3 setup.py install
安装pip3
  1. 下载
wget –no-check-certificate https://pypi.python.org/packages/source/p/pip/pip-8.0.2.tar.gz#md5=3a73c4188f8dbad6a1e6f6d44d117eeb 
  1. 解压
tar -zxvf pip-8.0.2.tar.gz
  1. 进入pip-8.0.2目录,编译安装:
cd pip-8.0.2
python3 setup.py build
python3 setup.py install

如果报错cannot import name HTTPSHandler.
执行下面的语句:

yum install openssl
yum install openssl-devel

安装完成后进入Python-3.6.4目录,再一次编译安装python

cd /root/Python-3.6.4
make && make install

此pip3安装包不是最新版本,可以进行安装,但是会提示两行黄色的警告,提示升级pip包
升级方法:

pip3 install --upgrade pip
[root@0404 ~]# pip3 install pyinstaller WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead. Collecting pyinstaller Using cached https://files.pythonhosted.org/packages/b0/e6/e5760666896739115b0e4538a42cdd895215581618ec885ad043dd35ee57/pyinstaller-4.10.tar.gz Requirement already satisfied: setuptools in /usr/lib/python3.6/site-packages (from pyinstaller) Requirement already satisfied: altgraph in ./.local/lib/python3.6/site-packages (from pyinstaller) Requirement already satisfied: pyinstaller-hooks-contrib>=2020.6 in ./.local/lib/python3.6/site-packages (from pyinstaller) Requirement already satisfied: importlib-metadata in ./.local/lib/python3.6/site-packages (from pyinstaller) Requirement already satisfied: zipp>=0.5 in ./.local/lib/python3.6/site-packages (from importlib-metadata->pyinstaller) Requirement already satisfied: typing-extensions>=3.6.4; python_version < "3.8" in ./.local/lib/python3.6/site-packages (from importlib-metadata->pyinstaller) Building wheels for collected packages: pyinstaller Running setup.py bdist_wheel for pyinstaller ... error Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__=&#39;/tmp/pip-build-9i8u5dao/pyinstaller/setup.py&#39;;f=getattr(tokenize, &#39;open&#39;, open)(__file__);code=f.read().replace(&#39;\r\n&#39;, &#39;\n&#39;);f.close();exec(compile(code, __file__, &#39;exec&#39;))" bdist_wheel -d /tmp/tmpmvsymh1kpip-wheel- --python-tag cp36: running bdist_wheel running build running build_bootloader No precompiled bootloader found or compile forced. Trying to compile the bootloader for you ... Setting top to : /tmp/pip-build-9i8u5dao/pyinstaller/bootloader Setting out to : /tmp/pip-build-9i8u5dao/pyinstaller/bootloader/build Python Version : 3.6.8 (default, Nov 14 2023, 16:29:52) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] Checking for &#39;gcc&#39; (C compiler) : /usr/bin
最新发布
03-22
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值