python3.7装pip3

插件库: https://pypi.org/

需要用到pip3安装mysql包

# install mysql-connector-python:
# pip3 install mysql-connector-python --allow-external mysql-connector-python

import mysql.connector  

安装pip3, 需要setuptools包

setuptools
找最新版本 https://pypi.org/project/setuptools

wget https://files.pythonhosted.org/packages/37/1b/b25507861991beeade31473868463dad0e58b1978c209de27384ae541b0b/setuptools-40.6.3.zip
unzip setuptools-40.6.3.zip
cd setuptools-40.6.3
python3 setup.py build
python3 setup.py install

pip3
找最新版本: https://pypi.org/project/pip/

wget https://files.pythonhosted.org/packages/45/ae/8a0ad77defb7cc903f09e551d88b443304a9bd6e6f124e75c0fbbf6de8f7/pip-18.1.tar.gz
tar -zxvf pip-18.1.tar.gz
cd pip-18.1
python3 setup.py build
python3 setup.py install

遇到的坑

ModuleNotFoundError: No module named '_ctypes'

因为python3.7需要 libffi-devel 包

yum install libffi-devel -y  (可能要需要其他的)

重新编译python(重点)

cd  /usr/local/python3/Python-3.7.1
make && make install

查看pip3版本, 有结果表示成功

# pip3 -V
pip 10.0.1 from /usr/local/python3/lib/python3.7/site-packages/pip (python 3.7)