首页 > 代码库 > 通过pip删除/管理django旧版本
通过pip删除/管理django旧版本
最近这段时间,准备继续把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‘]
本文出自 “暗黑魔君腾云端” 博客,请务必保留此出处http://clovemfong.blog.51cto.com/3297559/1556957
通过pip删除/管理django旧版本