【问题标题】:Changing Python path under Mac OS for applications other than the terminal在 Mac OS 下为终端以外的应用程序更改 Python 路径
【发布时间】:2014-02-23 16:59:26
【问题描述】:

我有一个 Python 脚本,我希望它能够在 Finder 或 Quicksilver 中运行,而无需大惊小怪。不幸的是,任何不使用终端的脚本运行方式都找不到我的库。

比如跑步

do shell script "~/anaconda/bin/python -c 'import sys; print len(sys.path)'"

来自 Applescript 的值为 13,但正在运行

~/anaconda/bin/python -c 'import sys; print len(sys.path)'

从终端给出 15。这让我觉得.bash_profile 可能不是修改我的 Python 路径的最佳位置。有没有办法对 Python 路径进行更改,这将影响终端和其他所有内容?如果是这样,那是修改 Python 路径的首选方法吗?

这是我的设置的一些版本信息:

Python 2.7.6 |Anaconda 1.8.0 (x86_64)| (default, Nov 11 2013, 10:49:09) 
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin

【问题讨论】:

    标签: python macos terminal finder pythonpath


    【解决方案1】:

    您可以设置环境变量PYTHONPATH。现在,我不是 Mac 用户,但根据一些研究,我会说你必须修改 ~/.MacOSX/environment.plist,如下所述:https://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPRuntimeConfig/Articles/EnvironmentVars.html#//apple_ref/doc/uid/20002093-BCIJIJBH

    【讨论】:

    • 你!设置 Mac 环境变量似乎是一个困难且不断变化的过程。请参阅 herehere。看来我需要的是另一回事,所以我开始my own question
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-08-13
    • 1970-01-01
    • 2021-12-03
    • 1970-01-01
    • 2016-05-06
    • 1970-01-01
    • 2012-01-19
    相关资源
    最近更新 更多