2

My project's running fine in virtualenv. Unfortunately, I can't yet run it via my IDE (Eric) because of the import troubles. It stands to reason, as I never told the IDE anything about virtualenv.

I know the drill ($ source project/bin/activate etc.), but lack general understanding. What constitutes "running inside virtualenv"? What IDE options might be relevant?

2
  • You have to set your paths correctly. I don't know Eric, but there has to be some sort of project related settings where you configure the interpreter and search paths. Commented Dec 10, 2014 at 9:52
  • My point exactly. What paths? I don't know anything about the touches that virtualenv adds to the universe. Commented Dec 10, 2014 at 10:00

3 Answers 3

2

I think the only required setting to run or debug code is path to python interpreter. Relevant IDE options could be SDK or Interpreter settings.

Note that you should run not default python (eg. /usr/bin/python) but python binary in your virtual environment (eg /path/to/virtualenv/bin/python)

Also there are some environment variables set by activate, but i think they aren't needed when you point to virtualenv python binary directly.

So, again, what activate does is only environment variables setup: at least, it modifies system $PATH in a way that python and pip commands points to executable files under path/to/virtaulenv/bin directiry.

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

Comments

1

As far as I know it is possible to run your script/project using your virtualenv simply by calling /path/to/your/venv/python your_script.py. To install new packages in your venv for example, you would run /path/to/your/venv/pip install some_package.

I guess the main advantage of "runnnig inside virtualenv" would be not being concerned about having to inform the location of python packages/executable everytime you want to run some script. But I lack general understanding too.

I usually install a virtualenv with the --no-site-packages option in order to have a "clean" installation of python.

--- EDIT ---

The second answer of this discussion has a nice explanation.

2 Comments

/home/alexey/spaces/python/py-procr/procr/bin/python Interpreter for the debug client (Eric) works. I have to grok it. (Python prefix to google?)
I didn't get it when you said "Python prefix to google?". I'm happy you made it work :)
0

Simply look at the project/bin/activate, everything you need is there to set up the appropriate search.

Usually the most important path is the PYTHONPATH which should point to the site-packages.

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.