Friday, 15 January 2010

python - Buildout installs django but can't import -



python - Buildout installs django but can't import -

here's buildout.cfg:

[buildout] parts = django [versions] djangorecipe = 1.5 django = 1.7 [django] recipe = djangorecipe project = timetable eggs =

here's routine setting project in new environment:

virtualenv . source bin/activate easy_install -u setuptools python bootstrap.py bin/buildout -v python manage.py migrate

when run bin/buildout, says django installed, , django binary in bin folder. when run manage.py, can't import django:

(timetable)mick88@s59gr2dmmd:~/timetable$ python manage.py migrate traceback (most recent phone call last): file "manage.py", line 8, in <module> django.core.management import execute_from_command_line importerror: no module named django.core.management

but works when install django using pip. why doesn't buildout install django in virualenv? how can prepare this?

buildout doesn't install in virtualenv. buildout collects python packages , adds programs bin/ directory have right python packages added sys.path.

so:

virtualenv/pip installs everything virtualenv. have activate virtualenv can modify pythonpath environment variable (and path variable). way python virtualenv's bin/ directory used , python packages lib/ dir.

buildout adds necessary "pythonpath" changes scripts in bin/, modifying sys.path setting straight instead of through environment variable.

the one thing need know should run bin/django instead of python manage.py. effect same, bin/django has right sys.path setting.

as example, @ contents of bin/django script. should this:

#!/usr/bin/python import sys sys.path[0:0] = [ '/vagrant', '/vagrant/eggs/djangorecipe-1.10-py2.7.egg', '/vagrant/eggs/django-1.6.6-py2.7.egg', '/vagrant/eggs/zc.recipe.egg-2.0.1-py2.7.egg', '/vagrant/eggs/zc.buildout-2.2.1-py2.7.egg', '/vagrant/eggs/south-1.0-py2.7.egg', ... ] import djangorecipe.manage if __name__ == '__main__': sys.exit(djangorecipe.manage.main('yoursite.settings'))

python django virtualenv buildout

No comments:

Post a Comment