简体   繁体   中英

How to point textmate to the same version of python I get at the command line

My Textmate uses python 2.6.1 and my system uses 2.6.5. This is not a big deal for the difference between them in terms of functionality, but all the packages that I installed with easy_install are not available to the Textmate version (2.6.1), though they are available to 2.6.5.

After researching this question I typed which python at the command line and learned that the desired python is /Library/Frameworks/Python.framework/Versions/2.6/bin/python .

I tried alternately adding a TM_PYTHON to the shell variables or a #! pointing to the path above. The result of each is the error msg IndexError: list index out of range , passed by module Q = sys.argv[1].

I cleared these out and tried creating a /usr/.profile with the line

alias python='/Library/Frameworks/Python.framework/Versions/2.6/bin/python'

with no effect.

Can anyone tell me what I am doing wrong? Thanks in advance.

You are nearly there.

In the menubar , click TextMate , then select Preferences from the drop-down menu, and then click Advanced from among the options at the top of the pop-up window. Next, click Shell Variables from among the three items near the top of the Advanced pane.

menubar > TextMate > Preferences > Advanced > Shell Variables

Here, you want to add two variable-value pairs, one for PATH and one for PYTHONPATH , so at the bottom left, click the "+" to add the first of these Variable-Value pair. You can edit either Variable or Value field by clicking in the text area.

The Value you want for PATH is the:

/Library/Frameworks/Python.framework/Versions/2.6/bin

make sure this is the first directory that appears in the Value field for the PATH variable. If you want to add other directory paths to that Value field, separate it from the one you just added using a colon ":"

Next, create the variable PYTHONPATH and for the value, specify the directory that holds your site packages . It is probably this:

/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages

but definitely verify this.

When you have added these two variable, make sure that you check the boxes for each in the far left column.

(You might need to re-start TextMate.)

Finally, make sure your hash bang line at the top of your python script template is consistent with what you just did--ie, the directory set for the value in PATH should simlink to the path specified in your pound bang line. The path specified in your pound hash bang should be a symlink to the python executable.

You might also want to add the line below at the beginning of your script file:

#!/opt/local/bin/python

The lion above is the result of:

which python

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM