三、pip安裝python
3.1 首先安裝setuptools軟件包:mysql
(1)下載setuptools包linux
wget https://pypi.python.org/packages/source/s/setuptools/setuptools-2.0.tar.gz
sql
(2)解壓setuptools包shell
(3)編譯setuptoolsbootstrap
(4)開始執行setuptools安裝bash
python setup.py install
3.2 安裝pip工具服務器
(1)下載PIP安裝包app
https://pypi.python.org/packages/11/b6/abcb525026a4be042b486df43905d6893fb04f05aac21c32c638e939e447/pip-9.0.1.tar.gz#md5=35f01da33009719497f01a4ba69d63c9
(2)解壓pip安裝包:curl
tar -xzvf pip-9.0.1.tar.gz
cd pip-9.0.1
python setup.py install
若是服務器中沒有安裝setuptools軟件包,則會提示如下錯誤:
提示錯誤:
Traceback (most recent calllast):
File "setup.py", line 5, in <module>
from setuptools import setup, find_packages
ImportError: Nomodule named setuptools
cd pip-9.0.1/ python setup.py install
安裝好pip以後,咱們就能夠直接使用pip安裝其餘第三方模塊包了:
pip install requests
若安裝後pip命令沒法使用,搜索系統中pip文件,建立命令連接
ln -s /usr/local/python27/bin/pip /usr/bin/pip
升級pip
pip install --upgrade pip
安裝python依賴包:
pip install pymysql
pip install wheel
pip install mysql-replication
安裝Python 3後
Python 3.6.1 (default, May 30 2017, 18:13:28)
# yum search # 安裝完後致使 yum 不可用 File "/usr/bin/yum", line 30 except KeyboardInterrupt, e: ^ SyntaxError: invalid syntax
解決 yum 不可用:
# vi /usr/bin/yum #!/usr/bin/python 改爲: #!/usr/bin/python_old # yum search
我出現了以下錯誤:
ModuleNotFoundError: No module named '_ctypes'
(無奈我是下載pip腳本安裝報錯的,才知道少了依賴包)
下載pip腳本安裝(參考:https://tecadmin.net/install-pip-linux/):
curl "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
可在安裝python3.7 以前 執行以下程序
yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel libffi-devel
yum install libffi-devel -y (包在base)