Warm tip: This article is reproduced from serverfault.com, please click

"Django not found" using venv in Eclipse/PyDev

发布于 2019-01-22 11:30:56

I'm not sure whether including python3.6/site-packages to the system pythonpath when setting up a PyDev workspace is correct.

I'm using Eclipse IDE for JavaScript and Web Developers (version 2018-12 4.10.0) with PyDev to use Django 2.1.5 from a virtual environment, on Ubuntu 18.04.

Main steps leading to the issue

  1. Set up the virtual env with: python3 -m venv djvenv

  2. Activate the venv in shell: source djvenv/bin/activate

  3. Install and test Django~=2.1.5 from requirements.txt using commands pip install -r requirements.txt and django-admin --version (returns 2.1.5)

  4. In Eclipse, create a new workspace in directory workspace.

  5. Set the Python interpreter to match the one from the virtual environment in directory djvenv via Window > Preferences > PyDev > Interpreters > Python Interpreter> (set interpreter name to e.g. python3-djenv and interpreter path to: /home/<username>/dj-workspace/djvenv/bin/python3), and accept.

  6. In the next prompt, tick the box to include the python3.6/site-packages directory to SYSTEM pythonpath. Click OK, then Apply and close

tick site-packages when prompted

Omitting to include the site-packages directory will result in a "Django not found." message when creating a Django project with File>New>Project>PyDev>PyDev Django Project.

Django not found image

Is it correct to include python3.6/site-packages here?

What bothers me is that it is specific to my project, while PyDev warns, in all caps:

“IMPORTANT: The folders for your PROJECTS should not be added here, but in your project configuration.”?

Questioner
sc28
Viewed
0
Fabio Zadrozny 2019-01-28 18:57:25

That's correct and that folder should be added...

-- what it means when it says that some file/folder is specific to your project is that files you're going to edit yourself should not be added under that configuration, and should be only added as a source folder in your own project.