简体   繁体   English

pip和virtualenv在错误的地方安装django的部分

[英]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. 我一直在使用virtualenv几个星期,直到今天没有任何问题。 Using pip to install my env using -r requirements.txt, it is installing part of Django (v1.5) in the wrong place. 使用pip使用-r requirements.txt安装我的env,它正在将错误的地方安装Django(v1.5)的一部分。 Instead of putting the entire source into: 而不是将整个来源放入:

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

it is putting parts of conf/ and contrib/ at: 它将conf /和contrib /的一部分放在:

env/django/

Of course, parts of Django like the admin page would not work. 当然,像管理页面这样的Django部分不起作用。 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. 我也尝试删除整个env目录并以相同的结果重新开始。

Any ideas as to why virtualenv & pip are splitting off parts of django into the wrong place (and how to fix it)? 关于为什么virtualenv和pip将django的部分分成错误的地方(以及如何修复它)的任何想法?

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 路径可能因操作系统而异,请检查此链接以查找您的pip缓存目录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: 原因是我们在框中以某种方式有一个损坏的django缓存,我通过在安装django时添加-v参数来查看详细输出:

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: 然后我添加了--no-cache-dir来安装一个干净的:

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. 它这次工作,virtualenv的根目录中没有conf和contrib文件夹,而是文件保留在我们期望的site-packages中。 and after we remove ~/.cache/pip, it also works fine with pip install django==1.5 在我们删除〜/ .cache / pip之后,它也适用于pip install django == 1.5

Add this line to the top of requirements.txt: 将此行添加到requirements.txt的顶部:

--no-binary Django

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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