pip install: How to force a specific package version

后端 未结 3 1381
一向
一向 2020-12-15 16:04

I\'m trying to install Django 1.4.3, but when I execute pip install, pip keeps installing Django 1.5 version instead 1.4.3

sudo pip install -I Django==1.4.3

3条回答
  •  猫巷女王i
    2020-12-15 16:45

    As limelight says, you should empty your cache and build directories, or pass in a temporary clean location with the --download-cache and flag.

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

    I'd like to warn any readers to not use sudo pip install to install Django. It installs Django system-wide. And changing the system-wide version could break system-packages that depend on it. For instance, Ubuntu MAAS and Cobbler depend on the system django package. These are typically services you don't want to break.

    If you need a different version than the system-package, use virtualenv to isolate your dependencies from the system.

    OP seems to be on OSX and I don't know of any server-wide Mac Django, but that may change. Consider installing python packages with sudo at par to changing the system-installed python with python 3; it might work for now, but have some paracetamol in stock, as you're in for some headaches.

提交回复
热议问题