I am using sublime text 2 for python development along with virtualenv!
The standard sublime text 2 build system uses the standard python install rather than my virtualenv where my packages are installed.
How can I get sublime text 2 to build using my virtualenv?
I currently use the terminal to activate my environment and run my scripts.
UPDATE: Never got it working, but seeing as i am using flask and it builds when you make a change, it's not a big issue
To install virtualenv, just use pip install virtualenv . To create a virtual environment directory with it, type virtualenv /path/to/directory . Activating and deactivating the virtual environment works the same way as it does for virtual environments in Python 3 (see above).
Multiple Python projects, each with their own dependencies can be effectively managed using separate virtual environments. Pipenv, Venv, and Pyenv are popular dependency management tools. The ActiveState Platform is a modern solution to dependency management. Virtualenv has been deprecated in Python 3.8.
These are almost completely interchangeable, the difference being that virtualenv supports older python versions and has a few more minor unique features, while venv is in the standard library.
You can also set the path for the build system to the bin
directory of your virtualenv, like so:
"build_systems": [ { "selector": "source.python", "env": {"PYTHONPATH":"/Users/user/project"}, "path":"/Users/user/work/myvirtualenv/bin:$PATH", "name": "Run virtualenv python", "cmd": ["python", "-u", "$file"], "file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)", "variants": [ { "name": "Run all Tests", "working_dir": "/Users/user/project", "cmd": ["nosetests"] } ] } ]
This also allows other tools, like nose
in the example, to find the correct python binary from the virtualenv.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With