【问题标题】:Updating django version in virtaulenv but still showing old version在 virtualenv 中更新 django 版本但仍显示旧版本
【发布时间】:2014-10-23 03:46:12
【问题描述】:

我正在尝试在 virtualenv 中升级我的 django 版本,它显示 django 已更新但仍未更新。

D:\testEnv>tan\Scripts\activate.bat
(tan) D:\testEnv>pip freeze
BeautifulSoup==3.2.1
Django==1.4.3
distribute==0.6.15
django-export-xls==0.1.1
jdcal==1.0
openpyxl==2.0.4
pypm==1.3.4
pythonselect==1.3
pywin32==214
virtualenv==1.6.1
wsgiref==0.1.2
xlwt==0.7.5

(tan) D:\testEnv>pip install Django --upgrade
Downloading/unpacking Django
  Downloading Django-1.7.1.tar.gz (7.5Mb): 7.5Mb 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.4.3
    Not uninstalling Django at c:\python27\lib\site-packages, outside environment D:\testEnv\tan
  Running setup.py install for Django

    warning: no previously-included files matching '__pycache__' found under directory '*'
    warning: no previously-included files matching '*.py[co]' found under directory '*'
    Installing django-admin-script.py script to D:\testEnv\tan\Scripts
    Installing django-admin.exe script to D:\testEnv\tan\Scripts
Successfully installed Django
Cleaning up...

(tan) D:\testEnv>pip freeze
BeautifulSoup==3.2.1
Django==1.4.3
distribute==0.6.15
django-export-xls==0.1.1
jdcal==1.0
openpyxl==2.0.4
pypm==1.3.4
pythonselect==1.3
pywin32==214
virtualenv==1.6.1
wsgiref==0.1.2
xlwt==0.7.5

(tan) D:\testEnv>python
ActivePython 2.7.2.5 (ActiveState Software Inc.) based on
Python 2.7.2 (default, Jun 24 2011, 12:21:10) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> dir(django)
['VERSION', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__', 'get_version']
>>> django.get_version
<function get_version at 0x022F7AB0>
>>> django.get_version()
'1.4.3'
>>>

由于我的 django 旧版本是 1.4.1,升级后它应该是 1.7.1 并且它显示消息 Successfully installed Django 但仍然显示旧版本的 django。 那么我应该如何在这里更新我的 django 版本。另外,我需要帮助来更新 django 版本 1.6.1。

【问题讨论】:

    标签: python django virtualenv


    【解决方案1】:

    我认为关键在于:

    Not uninstalling Django at c:\python27\lib\site-packages, outside environment D:\testEnv\tan
    

    你在你的 virtualenv 之外安装了一个 django,不知何故它忽略了你正在安装的那个并使用那个。删除它,然后重试。

    作为旁注,我尝试在 windows 中使用 django/python 很长时间......然后放弃了乞求 windows 让我工作并切换到另一个 SO。如果你想留在 Windows 我建议你至少使用vagrant,从长远来看会让你的生活更轻松。

    【讨论】:

    • 这很有帮助,但我根本不知道 vagrant。如果可能的话,可以为我提供一些帮助链接,如果有任何关于 vagrant 的 django 实现示例,那就太好了。
    • 试试:github.com/torchbox/vagrant-django-template。克隆后立即转到您的 requirements.txt 并将 django 更改为最新版本。记得阅读 vagrant 的文档。顺便说一句,你的问题解决了吗???
    • 我的问题实际上并没有解决,但是你给了我其他的方法,我觉得这更好,因为我开始了解 Vagrants 但仍然需要了解它。它是一种用于不同操作系统平台的虚拟机吗?
    • 是linux的虚拟机。您只需创建它,从机器上运行您的服务器(并在那里安装所有依赖项)并从 Windows 测试/升级您的基本代码。
    猜你喜欢
    • 2015-05-16
    • 2013-12-28
    • 2018-10-10
    • 1970-01-01
    • 1970-01-01
    • 2013-12-08
    • 2020-10-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多