试图学习django,我关闭了外壳,当我致电Python Manage.py Syncdb时,现在就遇到了这个问题,知道发生了什么吗?

我已经设置了一个数据库。我已经在文件夹django_bookmarks中设置了py。这里怎么了?

Traceback (most recent call last):
  File "manage.py", line 2, in <module>
    from django.core.management import execute_manager
ImportError: No module named django.core.management
my-computer:~/Django-1.1.1/django_bookmarks mycomp$ export PATH=/Users/mycomp/bin:$PATH
my-computer:~/Django-1.1.1/django_bookmarks mycomp$ python manage.py syncdb
Traceback (most recent call last):
  File "manage.py", line 2, in <module>
    from django.core.management import execute_manager
ImportError: No module named django.core.management
my-computer:~/Django-1.1.1/django_bookmarks mycomp$ 
有帮助吗?

解决方案

看起来Django在您的PythonPath中的任何目录中都不可用。

检查是否可以从命令提示符中获得Django:

$ python -c 'import django'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named django
$ # crash and burn...

假设您遇到了错误,请将Django的路径添加到PythonPath。

$ export PYTHONPATH=/path/to/django:$PYTHONPATH
$ python -c 'import django'
$ # hurray!

如果您将Django-1.1.1.tgz提取到〜/django-1.1.1中,请使用“〜/django-1.1.1” not“〜/django-1.1.1.1/django”,用于/path/to/to/django。

其他提示

您是否记得激活Virtualenv?那是我的问题。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top