32

我正在尝试安装 Django 1.4.3,但是当我执行 pip install 时,pip 继续安装 Django 1.5 版本而不是 1.4.3

sudo pip install -I Django==1.4.3

它返回:

Downloading/unpacking Django==1.4.3
  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 '*'
=== >>>> Requested Django==1.4.3, but installing version 1.5 <<<< ====
Installing collected packages: Django
  Found existing installation: Django 1.5
    Uninstalling Django:
      Successfully uninstalled Django
  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 '*'
    changing mode of /usr/local/bin/django-admin.py to 755
Successfully installed Django
Cleaning up...

但是如果我执行 pip freeze ,它会一直显示

姜戈==1.5

我究竟做错了什么?

谢谢

4

3 回答 3

16

这可以/应该/可以通过在 pip 中清除 Django 的构建目录来帮助。这有一个错误,因为版本 1.1请参阅此处了解详细信息

如果您使用的是 OS X 或类似 unix 的系统,则可以在此处开始检查这些文件夹:

~/.pip 
/tmp/pip-build-root (or pip-build-$USER, if you aren't running pip as root).

这是如果您在安装 Django 的第一个版本时没有指定新的构建文件夹。

祝你好运!

于 2013-03-28T19:59:11.513 回答
8

正如聚光灯所说,您应该清空缓存并构建目录,或者使用--download-cacheand 标志传入一个临时干净的位置。

$ pip help install
[...]
--download-cache <dir>      Cache downloaded packages in <dir>.
-b, --build <dir>           Directory to unpack packages into and build in. The default in a virtualenv is "<venv path>/build". The default for global installs is
                          "<OS temp dir>/pip-build-<username>".

我想警告任何读者不要使用sudo pip install安装 Django。它在系统范围内安装 Django。并且更改系统范围的版本可能会破坏依赖它的系统包。例如,Ubuntu MAAS 和 Cobbler 依赖于系统 django 包。这些通常是您不想破坏的服务。

如果您需要与系统包不同的版本,请使用virtualenv将您的依赖项与系统隔离。

OP 似乎在 OSX 上,我不知道任何服务器范围的 Mac Django,但这可能会改变。考虑使用sudoat par 安装 python 包,以使用 python 3 更改系统安装的 python;它现在可能有效,但有一些扑热息痛库存,因为你会头疼。

于 2013-03-29T09:03:21.097 回答
4

检查您的本地缓存并将其删除可能会有所帮助。我已经安装了 pymongo==2.5.2。为了安装pymongo==2.4.1,我删除了/tmp/pip-build-root/pymongo中的缓存。然后我成功安装了pymongo 2.4.1。

于 2013-07-20T06:39:17.083 回答