1. 程式人生 > >Python-2.7.6安裝~

Python-2.7.6安裝~

查詢 mod ctime enable .so usr red port 一行

一、檢查看依賴環境是否安裝

gcc –v
gcc是最基本的開發庫,gcc –v 查詢gcc的版本,如果有以下信息證明了gcc已安裝,如果出現“command not found”證明沒有安裝,需要通過yum去安裝,命令如下:
yumgroupinstall "Development Tools"
yum install zlib
yum install zlib-devel

安裝所有的開發工具,安裝後,再用gcc –v 是否安裝成功。
安裝openssl
yum install openssl* -y

二、python安裝
tar zxvf Python-2.7.6.tgz
cd Python-2.7.6

編譯:
./configure --prefix=/opt/python2.7.6 --enable-shared
由於python目前全面強制支持ssl,因此需要修改

#修改Setup文件
vi Python-2.7.6/Modules/Setup
#修改結果如下:
#Socket module helper for socket(2)
_socket socketmodule.ctimemodule.c
#Socket module helper for SSL support; you must comment out the other
#socket line above, and possibly edit the SSL variable:****

#SSL=/usr/local/ssl
_ssl _ssl.c \
-DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
-L$(SSL)/lib -lssl -lcrypto

make &&make install

mv /usr/bin/python /usr/bin/python.2.6.6
vim /usr/bin/yum,修改第一行為#!/usr/bin/python2.6.6,避免以後yum使用報錯。
ln -s /opt/python2.7.6/bin/python /usr/bin/python
ln -s /opt/python2.7.6/bin/python2.7 /usr/bin/python2.7

ln -s /opt/python2.7.6/lib/libpython2.7.so /lib64/libpython2.7.so
ln -s /opt/python2.7.6/lib/libpython2.7.so.1.0 /lib64/libpython2.7.so.1.0

至此安裝完成、可以手動驗證一下~

安裝python擴展程序
安裝setuptools
wget --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-1.4.2.tar.gz
tar xf setuptools-1.4.2.tar.gz
cd setuptools-1.4.2
/opt/python2.7.6/bin/python setup.py install

安裝pip
去下載pip https://pypi.python.org/simple/pip/ \復制裏面pip9.01的鏈接
wget --no-check-certificate https://pypi.python.org/packages/11/b6/abcb525026a4be042b486df43905d6893fb04f05aac21c32c638e939e447/pip-9.0.1.tar.gz#md5=35f01da33009719497f01a4ba69d63c9
tar xf pip-9.0.1.tar.gz
cd pip-9.0.1
/opt/python2.7.6/bin/python setup.py install
做軟連接
ln -s /opt/python2.7.6/bin/pip /usr/bin/pip

/opt/python2.7.6/bin/pip install urllib3
/opt/python2.7.6/bin/pip install requests
/opt/python2.7.6/bin/pip install threadpool
/opt/python2.7.6/bin/pip install pyOpenssl

安裝 supervisor
/opt/python2.7.6/bin/pip install supervisor
ln -s /opt/python2.7.6/bin/supervisorctl /usr/bin/supervisorctl
ln -s /opt/python2.7.6/bin/supervisord /usr/bin/supervisord
啟動 supervisord
/opt/python2.7.6/bin/supervisord -c /etc/supervisord.conf

Python-2.7.6安裝~