So, I have python 2.7.3 installed and I used the Django website https://docs.djangoproject.com/en/dev/topics/install/ to install Django on my Mac OS x Mountain Lion. I used pip and virtual env, I currently am able to use Django from my current terminal but, when I open a new terminal and try say:
所以,我安装了python 2.7.3,并使用Django网站https://docs.djangoproject.com/en/dev/topics/install/在我的Mac OS x Mountain Lion上安装Django。我使用了pip和虚拟环境,我目前能够从我当前的终端使用Django但是,当我打开一个新的终端并尝试说:
$ cd Django
$ cd djangowork
$ cd firstproj
$ python manage.py runserver
Traceback (most recent call last):
File "manage.py", line 8, in <module>
from django.core.management import execute_from_command_line
ImportError: No module named django.core.management
This is the error I get. I have looked online for a solution to my problem. It seems to be a common problem, dealing with the PATH. But, I cannot figure out how to fix it. Any help would be much appreciated thanks!
这是我得到的错误。我在网上寻找解决问题的方法。处理PATH似乎是一个常见问题。但是,我无法弄清楚如何解决它。任何帮助将非常感谢谢谢!
This is an example of what my working terminal looks like: (but if I exit out I lose everything)
这是我的工作终端的样子:(但如果我退出,我会失去一切)
(my_new_env)$ cd Django
(my_new_env)$ cd djangowork
(my_new_env)$ cd firstproj
(my_new_env)$ ls
firstproj manage.py testdb
(my_new_env)$ python manage.py runserver
Validating models...
0 errors found
October 31, 2012 - 18:51:22
Django version 1.6.dev20121029143154, using settings 'firstproj.settings'
Development server is running at http://.../
Quit the server with CONTROL-C.
1 个解决方案
#1
1
Notice how in the second case you have (my_new_env)
before the prompt, but not in the first? That's because only in the second case have you run virtual env properly. Make sure you run source my_new_env/bin/activate
before you run any python commands at the prompt. You should always have (my_new_env)
before the prompt in order to make sure your environment is set up properly. You have to do this in every terminal window that you open.
注意在第二种情况下你在提示之前有(my_new_env),但不是在第一种情况下?那是因为只有在第二种情况下才能正确运行虚拟环境。在提示符下运行任何python命令之前,请确保运行source my_new_env / bin / activate。您应该在提示之前始终拥有(my_new_env),以确保您的环境设置正确。您必须在打开的每个终端窗口中执行此操作。
#1
1
Notice how in the second case you have (my_new_env)
before the prompt, but not in the first? That's because only in the second case have you run virtual env properly. Make sure you run source my_new_env/bin/activate
before you run any python commands at the prompt. You should always have (my_new_env)
before the prompt in order to make sure your environment is set up properly. You have to do this in every terminal window that you open.
注意在第二种情况下你在提示之前有(my_new_env),但不是在第一种情况下?那是因为只有在第二种情况下才能正确运行虚拟环境。在提示符下运行任何python命令之前,请确保运行source my_new_env / bin / activate。您应该在提示之前始终拥有(my_new_env),以确保您的环境设置正确。您必须在打开的每个终端窗口中执行此操作。