Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse, pydev and virtual environments

Tags:

pydev

I have been searching for a good way to use python virtual environments from within eclipse.

The only suggestion I have found is to create a new eclipse-wide "interpreter" for each virtual environment. That is cumbersome for many project, but it works.

I want to have a virtual environment per project, so the path to the interpreter will have to change for each project.

1) can you define an interpreter specific for a project?

2) alternatively, how do you define an interpreter that use e.g. PROJECT_LOC variable?

any suggestions are welcome

like image 577
moozer Avatar asked Jul 31 '17 19:07

moozer


1 Answers

Unfortunately, the way that PyDev works, it expects all interpreters to be configured "eclipse-wide" (and then in a given project you can say which one should be used for that particular project if it shouldn't be the default one).

The other option is actually having one Eclipse workspace per project (then you'd configure a single "eclipse-wide" interpreter for it).

Another option, if the interpreters are from the same Python version and you're only changing the installed libraries would be creating a single "eclipse-wide" interpreter as the default one for all projects and then configuring the additional paths to be included in the PYTHONPATH per project.

Personally what I usually do is having one Eclipse workspace per project and having everything independent as I'm usually working on a single project at a time (so, I can focus only on what it's important for it), so, switching projects would be opening a new Eclipse instance pointing to the proper place, although it depends quite a lot on your use case (which you haven't actually made explicit) -- each project would have its own virtual env configured "eclipse-wide" (although in my case it's actually conda virtual envs).

like image 198
Fabio Zadrozny Avatar answered Sep 27 '22 22:09

Fabio Zadrozny