[英]Pip doesn't install packages to activated virtualenv, ignores requirements.txt
I am attempting to setup a development environment on my new dev machine at home. 我正在尝试在家里的新开发机器上设置开发环境。 I have just installed Ubuntu and now I am attempting to clone a remote repo from our web-server and install its dependencies so I can begin work. 我刚刚安装了Ubuntu,现在我正在尝试从我们的Web服务器克隆远程仓库并安装其依赖项,以便我可以开始工作。
So far I have manually installed virtualenv
and virtualenvwrapper
from pypi and edited my bash.rc appropriately to source my virtualenvs when i start my terminal. 到目前为止,我已经从pypi手动安装了virtualenv
和virtualenvwrapper
,并在我启动终端时适当地编辑了我的bash.rc以获取我的virtualenvs。 I then cloned my repo to ~/projects/project-name/websitename.com
. 然后我将我的repo克隆到~/projects/project-name/websitename.com
。 Then I used virtualenvwrapper
to mkvirtualenv env-name
from ~/projects/project-name/websitename.com
. 然后我从~/projects/project-name/websitename.com
使用了virtualenvwrapper
到mkvirtualenv env-name
。 This reflects exactly the file-structure/setup
of the web-server I am cloning from. 这恰好反映了我克隆的Web服务器的file-structure/setup
。 So far so good. 到现在为止还挺好。
I logged into the dev server and activate the virtualenv
there and use pip freeze -l > req.txt
to render a dependencies list and scp to my local machine. 我登录到dev服务器并在那里激活virtualenv
并使用pip freeze -l > req.txt
将依赖项列表和scp呈现给我的本地机器。 I activate the virtualenv
on my local machine, navigate to the ~/projects/project-name/websitename.com
and execute pip install -r path-to-req.txt
and it runs through all of the dependencies as if nothing is wrong. 我在我的本地机器上激活virtualenv
,导航到~/projects/project-name/websitename.com
并执行pip install -r path-to-req.txt
,它会运行所有依赖项,就好像没有错。 However, when i attempt to manage.py syncdb
i get an error about not finding core django packages. 但是,当我尝试manage.py syncdb
我收到一个关于找不到核心django软件包的错误。 What the hell? 我勒个去? So i figure somehow Django failed to install, i run pip install Django==1.5.1
and it completes successfully. 所以我想知道Django无法安装,我run pip install Django==1.5.1
并且它成功完成。 I got to setup my site again and get another error about no module named django_extensions
. 我必须再次设置我的网站,并得到另一个关于没有名为django_extensions
模块的错误。 Okay, what the hell with it, i just installed all of these packages with pip?! 好吧,到底是怎么回事,我刚用pip安装了所有这些包?!
So i pip freeze -l > test.txt
and cat test.txt
, what does it list? 所以我pip freeze -l > test.txt
和cat test.txt
,它列出了什么? Django==1.5.1
, the one package I just manually installed. Django==1.5.1
,我刚刚手动安装的一个包。 Why isn't pip installing my dependencies from my specified list into my virtualenv? 为什么不将我的依赖项从我的指定列表安装到我的virtualenv? What am I messing up here? 我在这里搞砸了什么?
-EDIT------------- -编辑 - - - - - - -
Which pip gives me the path to pip in my virtualenv 哪个点子给了我在我的virtualenv pip的路径
I have only 1 virtualenv and it is activated 我只有1个virtualenv,它被激活
My usual workflow is to 我通常的工作流程是
pip freeze > someFile.txt
and then install with 然后安装
pip install -r someFile.txt
So I'm certain that this should work just fine. 所以我确信这应该可以正常工作。 Unfortunately I can't really tell you anything besides make sure to check that 不幸的是,除了确保检查之外,我无法告诉你任何事情
You really are in the virtualenv that you think you are in. Make sure to run 你真的处在你认为自己所处的虚拟世界中。确保自己运行
workon yourVirtualEnvName
to activate it just in case that matters. 在重要的情况下激活它。
Make sure to check that pip is within your virtualenv. 一定要检查pip是否在你的virtualenv中。
which pip
gives me 给我
/path/to/home/.virtualenvs/myVirtEnv/bin/pip
Sorry I can't give you a more concrete answer. 对不起,我不能给你一个更具体的答案。 I have to do this semi-regularly and I've never had a problem with it skipping dependencies. 我必须半定期地执行此操作,并且我从未遇到过跳过依赖项的问题。 Best of luck! 祝你好运!
Struggled with some variation of this issue not long ago; 不久前,我对这个问题的一些变化感到挣扎; it ended up being my cluttered .bash_profile
file. 它最终成为我凌乱的.bash_profile
文件。
Make sure you don't have anything that might mess up your virtualenv inside your .bash_profile
/ .bashrc
, such as $VIRTUAL_ENV
or $PYTHONHOME
or $PYTHONPATH
environment variables. 确保在.bash_profile
/ .bashrc
没有任何可能会弄乱你的virtualenv的东西,比如$VIRTUAL_ENV
或$PYTHONHOME
或$PYTHONPATH
环境变量。
I know this is an old post, but I just encountered a similar problem. 我知道这是一个老帖子,但我刚遇到类似的问题。 In my case the cause was that I was running the pip install
command using sudo
. 在我的情况下,原因是我使用sudo
运行pip install
命令。 This made the command run globally and the packages install in the global python path. 这使得命令全局运行,并且包安装在全局python路径中。
Hope that helps somebody. 希望能帮到别人。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.