标签:
一、python升级到最新版(2.7.10)
1、检查python环境
[root@vice ~]# python
Python 2.7.5 (default, Jun 17 2014, 18:11:42)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
2、升级python到最新版2.7.10
下载Python-2.7.10.tgz到tmp目录
tar -zxvf Python-2.7.10.tgz
cd Python-2.7.10
./configure --prefix=/usr/local/python2.7
make
make install
安装好后运行下python看看是否正常
[root@vice bin]# /usr/local/python2.7.10/bin/python2.7 -V
Python 2.7.10
接下来需要创建一个链接来使系统默认python变为python2.7.10。
ln -fs /usr/local/python2.7.10/bin/python2.7 /usr/bin/python
运行python查看版本
[root@vice bin]# python -V
Python 2.7.10
3、进行更改后,yum果然无法运行了。修改/usr/bin/yum文件
vim /usr/bin/yum
将第一行的
#!/usr/bin/python中的python改为安装的python版本,我的如下:
#!/usr/bin/python2.7
[root@vice bin]# yum
已加载插件:fastestmirror
您需要给出命令
Usage: yum [options] COMMAND
显示出上述内容说明python更新成功
二、安装setuptools,安装pip
下载ez_setup.py
python ez_setup.py install
安装好后运行 easy_install
[root@vice tmp]# easy_install
Traceback (most recent call last):
File "/usr/bin/easy_install", line 5, in <module>
from pkg_resources import load_entry_point
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 3074, in <module>
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 3060, in _call_aside
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 3087, in _initialize_master_working_set
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 647, in _build_master
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 660, in _build_from_requirements
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 833, in resolve
pkg_resources.DistributionNotFound: The ‘setuptools==0.9.8‘ distribution was not found and is required by the application
发现命令运行会报错。重新安装python的distribution-0.6.49(0.7.3的会报错)
下载distribution链接https://pypi.python.org/pypi/distribute/0.6.49
tar -zxvf distribute-0.6.49.tar.gz
cd distribute-0.6.49
python setup.py install
安装后执行安装pip
easy_install pip
三、安装virtualenv与virtualenvwrapper
pip install -y virtualenv virtualenvwrapper
提示pip为找到命令
好吧,这样来搞 (是因为需要配置环境变量,不然找不到pip)
/usr/local/python2.7/bin/pip install virtualenv
/usr/local/python2.7/bin/pip install virtualenvwrapper
四、配置环境变量
vim /etc/profile
在最后加入下面内容
PYTHON_HOME=/usr/local/python2.7/bin/
WORKON_HOME=$HOME/.virtualenvs # 放所有虚拟环境的地方
PROJECT_HOME=$HOME/dev # 放所有项目的地方
export PATH=$PATH:$PYTHON_HOME:$WORKON_HOME:$PROJECT_HOME
保存退出
source /usr/local/python2.7/bin/virtualenvwrapper.sh
创建虚拟环境
mkvirtualenv demo1
workon
切换到环境
deactivate
注销当前环境
lsvirtualenv
列出所有环境
rmvirtualenv
删除环境
cpvirtualenv
复制环境
cdsitepackages
cd到当前环境的site-packages
目录
lssitepackages
列出当前环境中site-packages
内容
setvirtualenvproject
绑定现存的项目和环境
wipeenv
清除环境内所有第三方包
附录:
【(一些开发过长中需要用到的包,适情况下载安装)
yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers
yum -y install vim wget
】
centos7+python+virtualenv+virtualenvwrapper环境安装
标签:
原文地址:http://my.oschina.net/u/1786386/blog/464040