一、Python2 and pip2
由于Centos7自带Python2.7,所以就不说它的安装的,主要是安装pip2:
我的个人文件夹:
/home/jhuang/regit
执行命令:
wget -P /home/jhuang/regit https://bootstrap.pypa.io/get-pip.py && python /home/jhuang/regit/get-pip.py
二、 Pyhton3.8的安装
执行命令:
cd /home/jhuang/regit && curl -O https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tar.xz && tar -xvf Python-3.8.0.tar.xz && cd Python-3.8.0/ && ./configure && make && make install
注:python3.8的pip3的版本较低,需要升级:
pip3 install --upgrade pip
”,
pip3 install --upgrade setuptools
✿ 安装完后可能会出现的错误如下:
1.
ModuleNotFoundError: No module named '_ctypes
错误解决方案:
[jhuang@localhost ~]$ pip3 install bs4
Defaulting to user installation because normal site-packages is not writeable
Collecting bs4
Using cached bs4-0.0.1.tar.gz (1.1 kB)
ERROR: Command errored out with exit status 1:
command: /usr/local/bin/python3.8 -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/tmp/pip-install-6httvll3/bs4/setup.py’"’"’;
file
=’"’"’/tmp/pip-install-6httvll3/bs4/setup.py’"’"’;f=getattr(tokenize, ‘"’"‘open’"’"’, open)(
file
);code=f.read().replace(’"’"’\r\n’"’"’, ‘"’"’\n’"’"’);f.close();exec(compile(code,
file
, ‘"’"‘exec’"’"’))’ egg_info --egg-base /tmp/pip-install-6httvll3/bs4/pip-egg-info
cwd: /tmp/pip-install-6httvll3/bs4/
Complete output (11 lines):
Traceback (most recent call last):
File “”, line 1, in
File “/home/jhuang/.local/lib/python3.8/site-packages/setuptools/
init
.py”, line 19, in
from setuptools.dist import Distribution, Feature
File “/home/jhuang/.local/lib/python3.8/site-packages/setuptools/dist.py”, line 36, in
from setuptools import windows_support
File “/home/jhuang/.local/lib/python3.8/site-packages/setuptools/windows_support.py”, line 2, in
import ctypes
File “/usr/local/lib/python3.8/ctypes/
init
.py”, line 7, in
from _ctypes import Union, Structure, Array
ModuleNotFoundError: No module named '_ctypes’
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
安装:
yum -y install libffi-devel
,然后再去Python3.8的目录重新安装:
./configure && make && make install