【问题标题】:Aptana (eclipse) does not recognize modifications to PATH written in .bashrcAptana (eclipse) 无法识别以 .bashrc 编写的对 PATH 的修改
【发布时间】:2011-10-10 14:01:46
【问题描述】:

我今天早些时候遇到并解决了this problem,现在我遇到了类似的问题,但在另一个上下文中。

当我在我的 mac 终端 (Mac OS Lion) 中启动 python (2.7) 并执行时

import oursql

一切都很好。

当我在 Aptana IDE 中的 python 脚本中执行相同操作时,我收到以下错误。

    Traceback (most recent call last):
  File "/Users/salah/Documents/Aptana Studio 3 Workspace/pubmap/src/scripts/parse_all_dblp_authors.py", line 10, in <module>
    import oursql
ImportError: dlopen(/Library/Python/2.7/site-packages/oursql.so, 2): Library not loaded: libmysqlclient.18.dylib
  Referenced from: /Library/Python/2.7/site-packages/oursql.so
  Reason: image not found

这与我过去通过添加解决的上述问题中的错误相同

PATH=${PATH}:/usr/local/mysql/bin
export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:/usr/local/mysql/lib/"

到 .bashrc 和

if [ -f ~/.bashrc ]; then
    source ~/.bashrc
fi

到 .bash_profile。

为什么这对 Aptana 没有影响?顺便说一句,Aptana 是 eclipse 的衍生物,因此与 eclipse 相关的所有内容也应该与 Aptana 相关 - 至少我是这么认为的......

编辑:

彼得在下面的回答中提出的建议为我带来了一个可能的解决方案。只需将路径设置为 Aptana/Eclipse/Pydev 中 Python 的解释器选项即可。请参阅以下屏幕截图:

【问题讨论】:

  • 也许 aptana/Eclipse 只是设置了不同的 python 路径?
  • @matt b:有没有办法确定?
  • 我发现调试 python 搜索路径问题的最佳方法是在运行时检查它们。 os.environ['PATH'] 会告诉你 Python 已经给出的 PATH 环境变量。 sys.path 是 python 用来搜索模块的路径。

标签: python eclipse bash path aptana


【解决方案1】:

我使用 Pydev 已经有一段时间了,但 Pydev docs on configuring the interpreter 可能值得一看。

Python IDE 通常让您在从 IDE 运行时配置运行 python 的环境。

此外,让 .bashrc 更改您的 $PATH 只会更改 bash 会话的环境变量。除非您从 bash 运行 Aptana,否则更改 .bashrc 不会更改 Aptana 获得的环境变量。见setting-environment-variables-in-os-x

【讨论】:

  • 你的第一个链接给我带来了启示。我只是去了 python 的解释器选项并将“/usr/local/mysql/lib/”作为环境变量添加到 Environment 部分。我发布了一个截图作为编辑我的问题。谢谢!
【解决方案2】:

Aptana Studio 不读取 .bashrc。但是它确实按以下顺序包含其他文件:

if [ -f /etc/profile ] ; then . /etc/profile; fi   

if [ -f ~/.bash_profile ] ; then . ~/.bash_profile;
elif [ -f ~/.bash_login ] ; then . ~/.bash_login;
elif [ -f ~/.profile ] ; then . ~/.profile;

[[ -f ~/.aptanarc ]] && . ~/.aptanarc

干杯, 最大

【讨论】:

  • 我在上面提到过,我如何在 bash_profile 中获取 .bashrc。如果Aptana包含.bash_profile,会不会自动加载.bashrc?
猜你喜欢
  • 2017-05-09
  • 2017-06-21
  • 2011-05-22
  • 1970-01-01
  • 1970-01-01
  • 2017-12-18
  • 2013-02-18
  • 2013-03-15
  • 1970-01-01
相关资源
最近更新 更多