为了账号安全,请及时绑定邮箱和手机立即绑定

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

标签:
Python

通过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博客作者暗黑魔君的原创作品,如需转载,请注明出处,否则将追究法律责任


点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消