pip和virtualenv在错误的地方安装django的一部分 [英] pip and virtualenv installing parts of django in the wrong place

查看:58
本文介绍了pip和virtualenv在错误的地方安装django的一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用virtualenv几周了,直到今天没有任何问题.使用pip使用-r requirements.txt安装我的环境,它在错误的位置安装了Django(v1.5)的一部分.而不是将整个源放入:

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/

它将conf/和contrib/的一部分放在:

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

env/django/

当然,Django的某些部分(例如管理页面)将无法正常工作.当我将这两个目录移到正确的位置时,一切正常,并且没有重复的文件.我还尝试删除整个env目录,并以相同的结果重新开始.

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.

关于为什么选择virtualenv&的任何想法pip正在将Django的一部分拆分到错误的位置(以及如何修复)?

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

路径因操作系统而异,请检查此链接以找到您的pip缓存目录 https://pip.pypa.io/zh-CN/latest/reference/pip_install.html#caching

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

原因是在某种程度上我们的django缓存已损坏,我在安装django时通过添加-v参数来查看详细输出,从而发现了这一点:

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

在我们的情况下,

只是安装而没有下载任何内容.然后我添加了--no-cache-dir来安装一个干净的目录:

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

这一次有效,在virtualenv的根目录中没有conf和contrib文件夹,而是文件保留在站点包中,这是我们所期望的.在我们删除〜/.cache/pip之后,在pip install django == 1.5

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

这篇关于pip和virtualenv在错误的地方安装django的一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆