+16
Run Python script in a virtual environment (virtualenv)
The "Build" command for a Python script runs it through the global Python environment, but all my real code lives in virtual environments.
It would be helpful if Sublime Text had a way to choose a Python environment.
It would be helpful if Sublime Text had a way to choose a Python environment.
Service d'assistance aux clients par UserEcho
But now, best solution - add arguments using "Build with arguments". And nothing need to add in ST2.
http://www.sublimetext.com/forum/viewtopic.php?f=5&t=1699
{
"cmd": ["/home/you/.virtualenvs/env_name/bin/unit2", "discover"],
"working_dir": "${project_path:${folder}}"
}
Now the biggest problem is more that you can't easily create and switch build systems. You have to go menu, then submenu, then click. Then go menu again. Then run.
A litlle late, but here is a solution that I used - I`ve set as build_systems inside sublime project configs.
The example.sublime-project looks like:
{
"folders":
[
{
"path": "/path/to/your/project"
}
],
"build_systems":
[
{
"name": "Run Tests",
// activate the specific virtualenv for the project
"cmd": ["source", "/path/to/your/virtualenv/bin/activate"],
// now indicates a different folder to run the next cmd
"working_dir": "/path/to/to/you/django_project",
// runs the test
"cmd": ["python", "manage.py", "test"]
}
]
}