卸载旧版pip_通过pip删除/管理django旧版本

通过pip删除/管理django旧版本

暗黑魔君关注0人评论3256人阅读2014-09-22 15:11:55

最近这段时间,准备继续把django拾起来,断断续续的学习等于等于前功尽弃,学习的效果不是很好,加上这段时间工作上面的事情相对较少,今天中午在休息时间重新搭建了下django环境。

我是在ubuntu12.04(python:2.7.3),安装了django1.7,准备学习,翻阅django的官方文档看了看,注意到

This tutorial is written for Django 1.7 and Python 3.2 or later. If the

Django version doesn’t match, you can refer to the tutorial for your version

of Django by using the version switcher at the bottom right corner of this

page, or update Django to the newest version. If you are still using Python

2.7, you will need to adjust the code samples slightly, as described in

comments.

也就是说官方文档讲述的是django1.7跟python3.2版本或者更高版本的相关使用,相关的sample例子也是通过针对这样的版本进行。

于是乎,为了后面学习的时候不会遇到一些由于版本引起的诡异问题,还是采取跟官方文档适应的相关版本进行学习。所以就需要进行版本的变更。

This tutorial is written for Django 1.6 and Python 2.x. If the Django

version doesn’t match, you can refer to the tutorial for your version of

Django by using the version switcher at the bottom right corner of this page,

or update Django to the newest version. If you are using Python 3.x, be aware

that your code may need to differ from what is in the tutorial and you should

continue using the tutorial only if you know what you are doing with Python

3.x.

从以上官方文档上面来看,django1.6与python2.x版本使用较好。

不晓得各位是怎么安装django的,我是直接解压tgz包,然后python setup.py install 进行安装,问了一些python玩得好的朋友,说卸载django版本是不可以通过setup.py完成的,最好是通过pip进行版本管理。

root@ubuntu1204:~# sudo apt-get  install python-pip

root@ubuntu1204:~/Django-1.7# pip install django==1.6.5

Downloading/unpacking django==1.6.5

Downloading Django-1.6.5.tar.gz (6.6Mb): 6.6Mb downloaded

Running setup.py egg_info for package django

warning: no previously-included files matching '__pycache__' found under directory '*'

warning: no previously-included files matching '*.py[co]' found under directory '*'

Installing collected packages: django

Found existing installation: Django 1.7

Uninstalling Django:

Successfully uninstalled Django

Running setup.py install for django

changing mode of build/scripts-2.7/django-admin.py from 644 to 755

warning: no previously-included files matching '__pycache__' found under directory '*'

warning: no previously-included files matching '*.py[co]' found under directory '*'

changing mode of /usr/local/bin/django-admin.py to 755

Successfully installed django

Cleaning up...

如此,最终看下我们使用的学习组合应该就满足了官方文档版本需求了。

root@ubuntu1204:~# python -V

Python 2.7.3

root@ubuntu1204:~# python -c "import django; print(django.get_version())"

1.6.5

============================官方文档如是说==================================

If you previously installed Django using python setup.py install,

uninstalling is as simple as deleting the django directory from your Pythonsite-packages. To find the directory you need to remove, you can run the

following at your shell prompt (not the interactive Python prompt):

按照官方文档的意思,如果是通过python setup.py install的方式安装的话,查找到django的安装目录,然后执行删除即可。

root@ubuntu1204:~# python -c "import sys; sys.path = sys.path[1:]; import django; print(django.__path__)"

['/usr/local/lib/python2.7/dist-packages/django']

©著作权归作者所有:来自51CTO博客作者暗黑魔君的原创作品,如需转载,请注明出处,否则将追究法律责任

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值