我已经在虚拟环境中安装了Django,但是当我调用它时,它没有显示出来。
$ pip install django
Downloading/unpacking django
Downloading Django-1.7.1-py2.py3-none-any.whl (7.4MB): 7.4MB downloaded
Installing collected packages: django
Successfully installed django
Cleaning up...
$ python
Python 2.7.6 (default, Sep 9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named django
如何在虚拟环境中找到我的Django安装?
答案 0 :(得分:0)
virtualenv
扩展/覆盖你的系统python环境,并在系统python安装的路径前面添加它的路径。你看,你在系统.virtualenv
之前列出了site-packages
个网站包{ {1}},这是如何运作的。
您必须记住,激活当前命令行环境的补丁,因此您必须在运行python代码之前运行activate
,具体取决于您的virtualenv
。
更新:
解决方法是......!
simon@ri-desktop:~$ mkdir test
simon@ri-desktop:~$ cd test/
simon@ri-desktop:~/test$ ls
simon@ri-desktop:~/test$ virtualenv env
New python executable in env/bin/python
Installing setuptools, pip...done.
simon@ri-desktop:~/test$ ls
env
simon@ri-desktop:~/test$ source env/bin/activate
(env)simon@ri-desktop:~/test$ ls
env
(env)simon@ri-desktop:~/test$ mkdir project
(env)simon@ri-desktop:~/test$ ls
env project
(env)simon@ri-desktop:~/test$ cd project/
(env)simon@ri-desktop:~/test/project$