Skip to content

Instantly share code, notes, and snippets.

@swpu-lee
Created August 5, 2013 07:26
Show Gist options
  • Save swpu-lee/6154051 to your computer and use it in GitHub Desktop.
Save swpu-lee/6154051 to your computer and use it in GitHub Desktop.
直接下载安装包,装python2.7.5,默认应该会在/usr/bin/下面多一个python2.7
因为系统的python是2.6,所以如果用easy_install装了pip及virtualenv,那么全部的项目都不使用python2.7了
所以我们需要自己下包,安装pip等
(以下4步全都是使用su权限进行操作)
1、下载distribute,用于定位pypi内容的
wget --no-check-certificate https://pypi.python.org/packages/source/d/distribute/distribute-0.7.3.zip#md5=c6c59594a7b180af57af8a0cc0cf5b4a
解压后使用python2.7 setup.py install,于是我们得到了easy_install-2.7
2、将easy_install-2.7创建软链接到/usr/bin/目录下
ln -s /usr/local/python-2.7.5/bin/easy_install-2.7 /usr/bin/easy_install-2.7
有必要的话,还可以:
mv /usr/bin/easy_install /usr/bin/easy_install-sys
ln -s /usr/local/python-2.7.5/bin/easy_install-2.7 /usr/bin/easy_install
3、安装pip
easy_install-2.7 pip
ln -s /root/.local/bin/pip2.7 /usr/bin/pip2.7
4、安装virtualenv
pip2.7 install virtualenv
ln -s /usr/local/python-2.7.5/bin/virtualenv2.7 /usr/bin/virtualenv
在这一步我就不加2.7了,因为我的部署项目脚本在线下就直接使用的是virtualenv这个命令而不是virtualenv2.7
接下来运行virtualenv --no-site-packages env时报异常:
Traceback (most recent call last):
File "/usr/local/python-2.7.5/bin/virtualenv", line 5, in <module>
from pkg_resources import load_entry_point
ImportError: No module named pkg_resources
经过查证原因是上面的distribute包还是有问题,需要下载0.6.49的版本:
wget http://python-distribute.org/distribute_setup.py
python2.7 distribute_setup.py
done
参考:
https://gist.github.com/hangtwenty/5546945
http://toomuchdata.com/2012/06/25/how-to-install-python-2-7-3-on-centos-6-2/
http://stackoverflow.com/questions/1756721/what-is-causing-importerror-no-module-named-pkg-resources-after-upgrade-of-pyth
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment