2

I am trying to install the django autocomplete light examples : django autocomplete docs

with the following step (from the docs above):

virtualenv autocomplete_light_env
source autocomplete_light_env/bin/activate
git clone https://jpic@github.com/yourlabs/django-autocomplete-light.git
cd django-autocomplete-light/test_project
pip install -r requirements.txt
./manage.py runserver (also tried "python manage.py runserver")

But even on a clean environment, I am getting the following error when I try the to run the server (last step):

File "manage.py", line 8, in <module>
    from django.core.management import execute_from_command_line
ImportError: No module named django.core.management

I have tried a bunch of the suggestions from stackoverflow on how to fix this but nothing seems to work.

4

4 回答 4

1

只需将这些行添加到 autocomplete_light_env/test_project/requirements.txt

django

django-autocomplete-light

并再次运行pip install -r requirements.txt

于 2014-06-17T16:36:48.523 回答
1

我最终按照建议安装了 django(我需要使用 django 1.5 以实现 GAE 兼容性):

pip install -e git+https://github.com/django/django.git@1.5b2#egg=django

所以我走得更远,但现在它说:

ImportError: No module named autocomplete_light.example_apps.non_admin_add_another

我看到该模块在 settings.py 中被引用:

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',

'cities_light',

'autocomplete_light',
'autocomplete_light.example_apps.basic',
'autocomplete_light.example_apps.music',
'autocomplete_light.example_apps.autocomplete_test_case_app',
'autocomplete_light.example_apps.security_test',
'autocomplete_light.example_apps.dependant_autocomplete',
'autocomplete_light.example_apps.non_admin_add_another',

'navigation_autocomplete',
)

但我不知道如何解决这个问题。

更新:按照建议执行“python setup.py install”就可以了!

于 2014-06-17T04:29:44.020 回答
0

只需pip install django在您的环境中安装 Django。

于 2014-06-16T07:54:41.833 回答
0

您是在已经创建的虚拟环境上运行 Django 还是直接从根目录运行 Django?

我通常在每个网站的 virtualenv 中运行所有内容:

    django-admin.py startproject mysite
    cd mysite
    virtualenv env
    source env/bin/activate
    pip install django
    pip install django-autocomplete-light
    pip install ...

这样我就可以制作每个项目所需的包。

从您的最后一个错误来看,新的 autocomplete-light_env 上似乎没有安装 django

编辑:

请详细了解 virtualenv 的作用。从您的评论看来,您正在 virtualenv 之外安装 python 包,并因此出现 ModuleMissing 错误。

每次你在一个文件夹作为 virtualenv 的项目上工作时,你应该激活它,然后才安装包。使用“source env/bin/activate”激活它。将 env 替换为您安装 virtualenv 的文件夹。完成项目编辑后,运行“停用”

于 2014-06-15T19:43:28.933 回答