Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using virtualenv with sublime text 2

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

like image 725
Rigobert Song Avatar asked Aug 15 '12 07:08

Rigobert Song


People also ask

How do I enable virtualenv environment?

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).

Is virtualenv deprecated?

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.

Is VENV and virtualenv the same?

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.


1 Answers

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.

like image 104
user1248490 Avatar answered Sep 27 '22 16:09

user1248490