简体   繁体   中英

pip and virtualenv installing parts of django in the wrong place

I have been using virtualenv for a few weeks now without any problems until today. Using pip to install my env using -r requirements.txt, it is installing part of Django (v1.5) in the wrong place. Instead of putting the entire source into:

env/lib/python2.7/site-packages/django/

it is putting parts of conf/ and contrib/ at:

env/django/

Of course, parts of Django like the admin page would not work. When I moved these two dirs into the correct location, everything works fine, and there was no duplication of files. I also tried deleting the entire env directory and starting all over with the same result.

Any ideas as to why virtualenv & pip are splitting off parts of django into the wrong place (and how to fix it)?

Just met the same issue in our box too. fixed it by deleting this directory

rm -rf ~/.cache/pip

path may differ by OS, check this link to find your pip cache directory https://pip.pypa.io/en/latest/reference/pip_install.html#caching

The reason is we have a corrupted cache of django in the box somehow, I found this by adding -v parameter when you install django to see the verbose output:

pip install -v django==1.5

in our case, it's just installed without downloading anything. then i added --no-cache-dir to install a clean one:

pip install -v django==1.5 --no-cache-dir

it works this time, there is no conf and contrib folder in the root of virtualenv, instead the files stay in site-packages which is we expected. and after we remove ~/.cache/pip, it also works fine with pip install django==1.5

Add this line to the top of requirements.txt:

--no-binary Django

(from https://github.com/pypa/pip/issues/2823 )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM