Django没有在virtualenv中安装 [英] Django not installing in virtualenv
问题描述
我正在使用Linux(Lubuntu)并且已经安装了这样的虚拟化版本。
I am using Linux (Lubuntu) and have installed virtualenv like so
sudo easy_install virtualenv
然后执行
mkdir virt_env
并创建一个保存virtualenv的文件夹。接下来,我做了
and created a folder which holds the virtualenv's. Next, I did
virtualenv virt_env/virt1 --no-site-packages
并创建了环境。接下来,我激活了它:
and created the environment. Next, I activated it like so:
source virt_env/virt1/bin/activate
,一切顺利。然后,我做了
and all went well. Then, I did
sudo pip install Django
,它表示已经安装好了。我然后做了
and it said it is sucesfully installed. I then did
pip freeze
和Django未列出。我停用了virtualenv,并且执行
and Django was not listed. I deactivated the virtualenv and did
pip freeze
和Django在那里。为什么在全系统而不是在virtualenv中安装Django?然后我再次启动了virtualenv,尝试
and Django was there. Why did it install Django systemwide rather than in the virtualenv? I then activated the virtualenv again and tried
sudo pip install Django
,它说
Requirement already satisfied (use --upgrade to upgrade): Django in /usr/local/lib/python2.7/dist-packages
如何/ />
how do I install it in the virtualenv and not systemwide?
推荐答案
尝试将cd'ing转到virt1目录,然后运行 bin / pip install django
。您正在使用系统范围的点,而不是在virt1 / bin中。
Try cd'ing to the virt1 directory and then running "bin/pip install django
". You are using your system wide pip instead of the one in virt1/bin.
当您在目录中初始化时,virtualenv会创建四个目录( bin,include,lib,local
)。 lib是virtualenv保留所有virtualenv特定的python包的目录。使用bin / pip来安装django,您将在 lib / python2.x / site-packages /
virtualenv creates four directories(bin, include, lib, local
) when you initialize it in a directory. "lib" is the directory where virtualenv keeps all your virtualenv specific python packages. Use bin/pip to install django and you will find Django it in lib/python2.x/site-packages/
当在环境中安装python包时,请使用 bin / pip freeze
而不是 pip freeze
。
When looking for python packages installed in the environment, use "bin/pip freeze
" instead of the "pip freeze
".
步骤:
>> mkdir virtualenv_test
>> cd virtualenv_test
>> virutalenv . --no-site-packages
>> source bin/activate
>> bin/pip install django
>> bin/pip freeze
这篇关于Django没有在virtualenv中安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!