3

运行 Enthought Canopy 似乎会停用在 Canopy 环境中运行的 python 程序的正常 .profile PATH 信息 (OS X)。我需要使位置可搜索用户文件。

用户手册中没有说明如何执行此操作。有几个可能的地方可以输入这些信息(例如两个“激活”文件),但在其中添加额外的 PATH 信息没有效果。

那么它是如何完成的呢?

DN

4

4 回答 4

1

在 Mac OSX 10.6.8 这工作

% launchctl setenv PYTHONPATH /my/directory:/my/other/directory

然后启动 Canopy,您应该会在 sys.path 上看到 /my/directory 和 /my/other/directory

于 2013-04-29T14:25:22.200 回答
1

这来自于在 OS X 中设置环境变量的链接?在乔纳森发布的页面上。我在“/private/etc/launchd.conf”文件中的命令语法有误。

在 /private/etc 中创建或编辑文件“launchd.conf”(使用知道权限的编辑器,例如 BBEdit),其内容类似于以下行:

setenv PYTHONPATH /Users/<username>/Python/:/Users/<username>/AnotherPath/,

例如,将创建一个变量 PYTHONPATH,在重新启动后,Canopy 会看到该变量。

它也适用于其他环境变量。只需 launchd.conf 文件,更棒的是,它似乎可以在两次启动之间出现。

于 2013-04-30T07:32:55.380 回答
0

所描述的问题也出现在 Win 7 Canopy 安装中。

我试图将要导入的文件放置在 sys.path() 中提供的几个位置。

['', 'C:\Users\Owner\AppData\Local\Enthought\Canopy\User\Scripts\python27.zip', 'C:\Users\Owner\AppData\Local\Enthought\Canopy\App\appdata\canopy -1.0.0.1160.win-x86_64\DLLs', 'C:\Users\Owner\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.0.0.1160.win-x86_64\lib', 'C:\Users \Owner\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.0.0.1160.win-x86_64\lib\plat-win', 'C:\Users\Owner\AppData\Local\Enthought\Canopy\App\ appdata\canopy-1.0.0.1160.win-x86_64\lib\lib-tk', 'C:\Users\Owner\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.0.0.1160.win-x86_64', 'C:\Users\Owner\AppData\Local\Enthought\Canopy\User', 'C:\Users\Owner\AppData\Local\Enthought\Canopy\User\lib\site-packages', 'C:\Users\所有者\AppData\Local\Enthought\Canopy\System', 'C:\Users\Owner\AppData\Local\Enthought\Canopy\System\lib\site-packages', 'C:\Users\Owner\AppData\Local\Enthought\Canopy\System\lib\site-packages\PIL', ' C:\Users\Owner\AppData\Local\Enthought\Canopy\System\lib\site-packages\win32', 'C:\Users\Owner\AppData\Local\Enthought\Canopy\System\lib\site-packages\ win32\lib', 'C:\Users\Owner\AppData\Local\Enthought\Canopy\System\lib\site-packages\Pythonwin', 'C:\Users\Owner\AppData\Local\Enthought\Canopy\App\ appdata', 'C:\Users\Owner\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.0.0.1160.win-x86_64\lib\site-packages', 'C:\Users\Owner\AppData\ Local\Enthought\Canopy\App\appdata\canopy-1.0.0.1160.win-x86_64\lib\site-packages\IPython\extensions']\Users\Owner\AppData\Local\Enthought\Canopy\System\lib\site-packages\PIL', 'C:\Users\Owner\AppData\Local\Enthought\Canopy\System\lib\site-packages\win32' , 'C:\Users\Owner\AppData\Local\Enthought\Canopy\System\lib\site-packages\win32\lib', 'C:\Users\Owner\AppData\Local\Enthought\Canopy\System\lib\站点包\Pythonwin','C:\Users\Owner\AppData\Local\Enthought\Canopy\App\appdata','C:\Users\Owner\AppData\Local\Enthought\Canopy\App\appdata\canopy- 1.0.0.1160.win-x86_64\lib\site-packages','C:\Users\Owner\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.0.0.1160.win-x86_64\lib\site-packages \IPython\扩展']\Users\Owner\AppData\Local\Enthought\Canopy\System\lib\site-packages\PIL', 'C:\Users\Owner\AppData\Local\Enthought\Canopy\System\lib\site-packages\win32' , 'C:\Users\Owner\AppData\Local\Enthought\Canopy\System\lib\site-packages\win32\lib', 'C:\Users\Owner\AppData\Local\Enthought\Canopy\System\lib\站点包\Pythonwin','C:\Users\Owner\AppData\Local\Enthought\Canopy\App\appdata','C:\Users\Owner\AppData\Local\Enthought\Canopy\App\appdata\canopy- 1.0.0.1160.win-x86_64\lib\site-packages','C:\Users\Owner\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.0.0.1160.win-x86_64\lib\site-packages \IPython\扩展']\Users\Owner\AppData\Local\Enthought\Canopy\System\lib\site-packages\win32\lib', 'C:\Users\Owner\AppData\Local\Enthought\Canopy\System\lib\site-packages\ Pythonwin'、'C:\Users\Owner\AppData\Local\Enthought\Canopy\App\appdata'、'C:\Users\Owner\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.0.0.1160。 win-x86_64\lib\site-packages', 'C:\Users\Owner\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.0.0.1160.win-x86_64\lib\site-packages\IPython\extensions ']\Users\Owner\AppData\Local\Enthought\Canopy\System\lib\site-packages\win32\lib', 'C:\Users\Owner\AppData\Local\Enthought\Canopy\System\lib\site-packages\ Pythonwin'、'C:\Users\Owner\AppData\Local\Enthought\Canopy\App\appdata'、'C:\Users\Owner\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.0.0.1160。 win-x86_64\lib\site-packages', 'C:\Users\Owner\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.0.0.1160.win-x86_64\lib\site-packages\IPython\extensions ']\Users\Owner\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.0.0.1160.win-x86_64\lib\site-packages\IPython\extensions']\Users\Owner\AppData\Local\Enthought\Canopy\App\appdata\canopy-1.0.0.1160.win-x86_64\lib\site-packages\IPython\extensions']

我发现的唯一解决方案是使用:

sys.path.append()

于 2013-04-14T03:20:02.687 回答
0

以下文章是否充分回答了这个问题?: https: //support.enthought.com/entries/23665767-How-do-I-set-PYTHONPATH-and-other-environment-variables-for-Canopy-

于 2013-04-28T03:16:38.013 回答