码迷,mamicode.com
首页 > 移动开发 > 详细

python虚拟环境Virtualenvwrapper无法升降级虚拟环境软件解决方法

时间:2015-08-05 21:47:41      阅读:691      评论:0      收藏:0      [点我收藏+]

标签:

virtualenv用于创建独立的Python环境,多个Python相互独立,互不影响,它能够在没有权限的情况下安装新套件,不同应用可以使用不同的套件版本,套件升级不影响其他应用。

Virtaulenvwrapper则是virtualenv的扩展包,用于更方便管理虚拟环境,如,新增,删除,复制,切换等。

最近在利用Virtaulenvwrapper的mkvirtualenv创建Python虚拟环境的时候,发现在创建的虚拟环境中升级django为1.8的时候,出现无法升级的状况:(机器外部已经安装django-1.6.10)

shenweiyan@localhost 09:39:25 ~ 
=> workon test
(test)shenweiyan@localhost 09:39:30 ~ 
=> pip install --upgrade django==1.8
You are using pip version 6.0.6, however version 7.1.0 is available.
You should consider upgrading via the pip install --upgrade pip command.
Collecting django==1.8
  Using cached Django-1.8-py2.py3-none-any.whl
Installing collected packages: django
  Found existing installation: Django 1.6.10
    Not uninstalling Django at /usr/local/python2.7/lib/python2.7/site-packages, outside environment /App/pyweb/test
 
Successfully installed django-1.6.10

 

提示无法在/usr/local/python2.7/lib/python2.7/site-packages安装django-1.8。其原因就在于在全局环境变量中已经指定了PYTHONPATH,所以在安装django的时候会把1.8的版本默认安装到指定的PYTHONPATH下,从而导致django-1.8无法成功安装。

root@localhost 09:39:04 ~ 
=> cat /etc/profile
......
export PATH=/usr/local/python2.7/bin:$PATH
export PYTHONPATH=/usr/local/python2.7/lib/python2.7/site-packages:/usr/lib/python2.6/site-packages:$PYTHONPATH

 

所以,把/etc/profile全局变量中的PYTHONPATH注释掉,再重新登录虚拟环境进行安装升级就ok了。

shenweiyan@localhost 10:07:42 ~ 
=> workon test            
(test)shenweiyan@localhost 10:07:45 ~ 
(test)shenweiyan@localhost 10:09:34 ~ 
=> pip install django==1.8.3 
You are using pip version 7.0.3, however version 7.1.0 is available.
You should consider upgrading via the pip install --upgrade pip command.
Collecting django==1.8.3
  Using cached Django-1.8.3-py2.py3-none-any.whl
Installing collected packages: django
  Found existing installation: Django 1.6.10
    Uninstalling Django-1.6.10:
      Successfully uninstalled Django-1.6.10
Successfully installed django-1.8.3

python虚拟环境Virtualenvwrapper无法升降级虚拟环境软件解决方法

标签:

原文地址:http://www.cnblogs.com/shenweiyan/p/4705763.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!