10

I'd like to work in my virtualenv from textmate 2, but i really have no idea on how to indicate text mate the env of python it has to use.

If anyone can help, thank you.

4 Answers4

11

If there's a project folder associated with your virtualenv, you could add a .tm_properties file that contains something like

TM_PYTHON = "$HOME/.virtualenvs/example/bin/python"

In fact, I might make a project template for virtualenvwrapper that does just that for all new projects.

To set it globally in TextMate 2, just add TM_PYTHON to the Variables section of the preferences. You should be able to set PYTHONPATH the same way (per-project or application-wide).

Rob McBroom
  • 308
  • 3
  • 9
3

You will probably need to use a wrapper script, to first activate the virtualenv and then (within virtualenv) start the textmate2 process.

wrapper example:

#!/bin/sh

# load the virtual env
. $HOME/MY-VENV/bin/activate

# run the editor
/path/to/textmate "$@"
Michał Šrajer
  • 30,364
  • 7
  • 62
  • 85
0

This article essentially shows Rob McBroom and K.-Michael Aye's answers in greater detail.

NOTE: It seems that you must disable any she-bangs (#!/usr/bin/env python in my case) for this to work.

Community
  • 1
  • 1
ssc
  • 9,528
  • 10
  • 64
  • 94
-1

TM_PYTHON in the TM2 preferences for environment variables determines the Python to the preferred interpreter, but I did not find out yet, how to set the PYTHONPATH for TM2 yet.

K.-Michael Aye
  • 5,465
  • 6
  • 44
  • 56