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

简介:

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

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

1
2
3
4
5
6
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例子也是通过针对这样的版本进行。

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

1
2
3
4
5
6
7
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进行版本管理。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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...

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


1
2
3
4
root@ubuntu1204:~ # python -V
Python 2.7.3
root@ubuntu1204:~ # python -c "import django; print(django.get_version())"
1.6.5

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

1
2
3
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的安装目录,然后执行删除即可。

1
2
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博客,原文链接:http://blog.51cto.com/clovemfong/1556957,如需转载请自行联系原作者
目录
相关文章
|
3月前
|
API 数据库 Python
Python 教程之 Django(8)在 Django 管理界面中渲染模型
Python 教程之 Django(8)在 Django 管理界面中渲染模型
23 0
Python 教程之 Django(8)在 Django 管理界面中渲染模型
|
5月前
|
搜索推荐 算法 前端开发
旅游管理与推荐系统Python+Django网页平台+协同过滤推荐算法
旅游管理与推荐系统Python+Django网页平台+协同过滤推荐算法
146 0
|
3月前
|
搜索推荐 算法 前端开发
美食物管理与推荐系统Python+Django网站开发+协同过滤推荐算法应用【计算机课设项目推荐】
美食物管理与推荐系统Python+Django网站开发+协同过滤推荐算法应用【计算机课设项目推荐】
101 4
美食物管理与推荐系统Python+Django网站开发+协同过滤推荐算法应用【计算机课设项目推荐】
|
9天前
|
数据处理 数据库 开发者
Django中的自定义管理命令:扩展管理功能的途径
【4月更文挑战第15天】Django教程:介绍如何创建和使用自定义管理命令以扩展框架功能。在应用的`management/commands`目录下创建Python文件,继承`BaseCommand`,实现`handle`方法。示例代码展示了如何定义参数和执行逻辑。自定义命令适用于批量数据处理、定期任务、项目初始化和自定义迁移操作。注意文件位置、命令安全性和稳定性。自定义管理命令能提升开发和维护效率。
|
9天前
|
关系型数据库 API 数据库
Django中的数据库事务管理:确保数据一致性
【4月更文挑战第15天】Django框架提供强大的数据库事务管理,确保ACID属性,保证数据一致性和完整性。文章深入讨论了Django事务管理,包括使用`@transaction.atomic`装饰器和`transaction.atomic()`上下文管理器手动控制事务,以及低级API进行精细管理。注意避免长时间事务、选择合适隔离级别、正确处理异常及了解数据库特性。掌握这些技巧对构建可靠Web应用至关重要。
|
4月前
|
搜索推荐 算法 前端开发
商品购物管理与推荐系统Python+Django网页界面+协同过滤推荐算法
商品购物管理与推荐系统Python+Django网页界面+协同过滤推荐算法
67 0
|
3月前
|
存储 安全 数据库
关于“Python”Django 管理网站的核心知识点整理大全52
关于“Python”Django 管理网站的核心知识点整理大全52
19 0
|
4月前
|
算法 关系型数据库 API
Python【算法中心 02】Web框架Django管理页面使用(管理员账号创建+API使用+应用添加)GreenPlum数据库引擎及API测试
Python【算法中心 02】Web框架Django管理页面使用(管理员账号创建+API使用+应用添加)GreenPlum数据库引擎及API测试
42 0
|
4月前
|
人工智能 开发工具 数据库
Django实践-03模型-02基于admin管理表
Django实践-03模型-02基于admin管理表
Django实践-03模型-02基于admin管理表
|
4月前
|
人工智能 测试技术 Linux
软件测试/人工智能|使用 Pip 管理 Python 包
软件测试/人工智能|使用 Pip 管理 Python 包
36 1