3

mac ox 8.2, eclipse juno, python 2.7, django 1.4.1, pydev 2.7.1.2012100913

I'm relative new with python/django and I'm trying to get it to work with pydev in a virtualenvironment. I set up the virtualenvironment installed django and successfully created and started a django project. After that I decided that I want to use my favorite editor eclipse.

I created a new pydev/django project, configured and selected a new interpreter (from virtualenv) and used that, I also included the virtualenv/lib/python2.7/site-packages/django in the interpreter libraries. However after going the next dialog, I got an error message "Django not found"

I went over the documentation but I haven't found any solution yet.

I was also wondering whether the workenvironment (or the actual code) needs to live in a subdirectory of the virtualenv directory) And whether the virtualenv must be activated (I suppose so), tried all these options but no luck yet.

2
  • can you import django from shell within the virtualenv? Commented Oct 17, 2012 at 20:06
  • import django, in Python shell is working from virtualenv, as well as ./manage.py shell Commented Oct 17, 2012 at 20:11

2 Answers 2

2
+200

As far as I'm aware you don't need the django installation (i.e., virtualenv/lib/python2.7/site-packages/django) in your interpreter libraries. Having the site-packages in there (i.e., virtualenv/lib/python2.7/site-packages) should suffice for your interpreter to find any django.* package.

Sign up to request clarification or add additional context in comments.

Comments

2

putting this in your interpreter libraries:

virtualenv/lib/python2.7/site-packages/django

wiil not work, because there is no virtualenv/lib/python2.7/site-packages/django/django (yes, twice), this translates to the following:

export PYTHONPATH=<...virtualenv>/lib/python2.7/site-packages/django:$PYTHONPATH
python -c 'import django'

which fails with ImportError message. you need to give the parent directory.

virtualenv/lib/python2.7/site-packages

which translates to the following:

export PYTHONPATH=<...virtualenv>/lib/python2.7/site-packages:$PYTHONPATH
python -c 'import django'

.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.