简体   繁体   English

如何将 textmate 指向我在命令行获得的相同版本的 python

[英]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.我的 Textmate 使用 python 2.6.1,我的系统使用 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.这对于它们之间在功能上的差异来说并不是什么大问题,但是我使用 easy_install 安装的所有软件包都不适用于 Textmate 版本(2.6.1),尽管它们适用于 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 .在研究了这个问题之后,我在命令行中输入which python并了解到所需的 python 是/Library/Frameworks/Python.framework/Versions/2.6/bin/python

I tried alternately adding a TM_PYTHON to the shell variables or a #!我尝试将TM_PYTHON交替添加到 shell 变量或#! 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].每个结果都是错误消息IndexError: list index out of range ,由模块 Q = sys.argv[1] 传递。

I cleared these out and tried creating a /usr/.profile with the line我清除了这些并尝试使用该行创建/usr/.profile

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.菜单栏中,单击TextMate ,然后从下拉菜单中单击 select首选项,然后从弹出窗口 window 顶部的选项中单击高级 Next, click Shell Variables from among the three items near the top of the Advanced pane.接下来,从高级窗格顶部附近的三个项目中单击Shell 变量

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.在这里,您要添加两个变量值对,一个用于PATH ,一个用于PYTHONPATH ,因此在左下角,单击“+”以添加这些变量值对中的第一个。 You can edit either Variable or Value field by clicking in the text area.您可以通过单击文本区域来编辑变量或值字段。

The Value you want for PATH is the:您想要的PATH值是:

/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.确保这是出现在 PATH 变量的值字段中的第一个目录。 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 .接下来,创建变量PYTHONPATH并为值指定保存站点包的目录。 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.) (您可能需要重新启动 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.最后,确保您的 python 脚本模板顶部的hash bang line 与您刚刚所做的一致 - 即,为 PATH 中的值设置的目录应该链接到您的磅 bang 行中指定的路径。 The path specified in your pound hash bang should be a symlink to the python executable.您的磅 hash bang 中指定的路径应该是 python 可执行文件的符号链接。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何让命令行中的 python3 指向我用 homebrew 安装的版本? - How do I get python3 in the command line to point to the version I installed with homebrew? 如何让我的python(2.5版)脚本在文件夹而不是命令行中运行jar文件? - How can I get my python (version 2.5) script to run a jar file inside a folder instead of from command line? 如何通过单行或命令行选项获取Python解释器的详细版本? - How would I get the detailed version of my Python interpreter via a one-liner or command-line option? 如何让pip指向更新版本的Python - How to get pip to point to newer version of Python 如何使用 vanila python 在命令行上获取 arguments? - How can I get the arguments on a command-line with vanila python? 如何获得直线上的曲线点? - How do I get a curve point on a line? 如何在 Windows 上退出 Python 3.8 版的 Python 命令行 - How to exit Python Command Line on Windows for Python version 3.8 如何使命令行使用特定版本的python? - How do I make my command line use a specific version of python? 如何在python的同一行打印多个命令行arguments的内容? - How to print the content of multiple command line arguments on the same line in python? 如何在python(Windows)中通过命令行获取PID? - How to get PID by command line in python (windows)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM