Sublime Forum

Elegant solution for virtualenv?

#1

Hi!

I’m looking for an elegant solution for working with Python virtualenv. Does anyone have one? I’ve tried to search for one, but I haven’t found any that aren’t very hackish.

Best regards,
ultra

0 Likes

#2

Hi

I’ve created a virtualenv for MyProject. When workon MyProject python 3.4 is used. When opening the project in ST3, python 2 is used.
I’ve changed my project settings to use:
“settings’”: {“python_interpreter”: “~/.virtualenv/MyProject/bin/python”}
If I cmd+B on a test.py file with print(sys.version_info) it still gives me python 2
Executing from the command line gives my python 3

What else do I need to change to make ST3 work with my virtualenv?

Kind regards

Jan

0 Likes

#3

Apparently I needed to change my Build System to “Anaconda Python Builder” as well :blush:

0 Likes

#4

Yes, you need to adjust the build for python. I suppose an auto-search plugin that looks for potential viertualenvs before defaulting to the standard interpreter is reasonable.

0 Likes

#5

Here’s the build systems I wrote for virtualenvs. It will create them in the script directory if they don’t exist.

gist.github.com/corndogcomputer … dd4907e15c

0 Likes