9780j 发表于 2016-2-15 11:06:00

python2.7.8安装

1、mkdir -p /usr/local/python && cd /usr/local/python && wget https://www.python.org/ftp/python/2.7.8/Python-2.7.8.tgz && tar zxvf Python-2.7.8.tgz && cd Python-2.7.8 && ./configure --prefix=/usr/local/python && make && make install
mv /usr/bin/python /usr/bin/python_bak && ln -s /usr/local/python/bin/python2.7 /usr/bin/python



恢复:
rm -rf /usr/bin/python
mv /usr/bin/python_bak /usr/bin/python

如果是Linux6的系统,需要修改yum的配置
vi /usr/bin/yum
#!/usr/bin/python

修改为:

#!/usr/bin/python2.6


wget https://pypi.python.org/packages/source/e/ez_setup/ez_setup-0.9.tar.gz && tar zxvf ez_setup-0.9.tar.gz && cd ez_setup-0.9 && /usr/local/python/bin/python2.7 ez_setup.py
wget https://pypi.python.org/packages/source/p/pip/pip-6.1.1.tar.gz#md5=6b19e0a934d982a5a4b798e957cb6d45 && tar zxvf pip-6.1.1.tar.gz && cd pip-6.1.1 && /usr/local/python/bin/python2.7 setup.py install


1.urllib2.URLError: <urlopen error unknown url type: https>

python 出现'module' object has no attribute 'HTTPSHandler' 错误,是因为你编译python的时候没有把ssl模块编译进去,重新编译安装python,并把ssl模块包含进去就可以了
下载最新版openssl(http://www.openssl.org/source/)
wget http://www.openssl.org/source/openssl-1.0.2-latest.tar.gz && tar zxvf openssl-1.0.2-latest.tar.gz && cd openssl-1.0.2d

编译安装
./config --prefix=/usr/local/openssl --shared && make && make install
cd python源码目录/Modules
vi Setup.dist
找到

# 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即可


tarfile.ReadError: file could not be opened successfully

来源: http://bitlanghen.iyunv.com/blog/1181589

解决:出现tarfile.ReadError: file could not be opened successfully,下一个zlib-devel安装,重新安装python就OK了

yum install zlib zlib-devel

页: [1]
查看完整版本: python2.7.8安装