永久添加到MAC上的DYLD_LIBRARY_PATH会导致X11错误 [英] Permanently adding to DYLD_LIBRARY_PATH on MAC causes X11 errors

查看:257
本文介绍了永久添加到MAC上的DYLD_LIBRARY_PATH会导致X11错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Python 2.7并试图导入graph_tool,看来我的libboost_thread-mt.dylib位于/opt/local/lib中,而不是/usr/local/lib中.

I am using Python 2.7 and am trying to import graph_tool, and it seems that my libboost_thread-mt.dylib is located in /opt/local/lib rather than /usr/local/lib.

如果我启动X11终端并输入

If I start an X11 terminal and type in

   export DYLD_LIBRARY_PATH='/opt/local/lib' 

然后Python成功导入了graph_tool.另一方面,如果我添加

then Python successfully imports graph_tool. On the other hand, if I add

   export DYLD_LIBRARY_PATH='/opt/local/lib':$DYLD_LIBRARY_PATH

~/.bash_profile,X11停止工作.我对这里发生的事情感到非常困惑.为什么不能在不破坏计算机的情况下将/opt/local/lib永久添加到$DYLD_LIBRARY_PATH?

to ~/.bash_profile, X11 stops working. I am really confused as to what is happening here. Why can't I add /opt/local/lib to $DYLD_LIBRARY_PATH permanently without destroying my computer?

我们非常感谢您的帮助.谢谢!

Any help is much appreciated. Thanks!

推荐答案

尝试永久设置DYLD_LIBRARY_PATH几乎总是表明您做错了事.在OS X上,经过精心设计的组件将绝对路径或RPATH嵌入共享库中,因此几乎不需要设置环境变量来覆盖库搜索路径.

Trying to permanently set DYLD_LIBRARY_PATH is almost always an indication that you are doing something wrong. On OS X, well-designed components embed absolute paths or RPATHs to shared libraries so that setting environment variables to override library search paths should seldom be needed.

由于显示路径/opt/local/lib,因此我假设您正在使用MacPorts,因为这是其默认安装路径.如果您无法导入MacPorts安装的Python程序包,则可能是您使用了错误的Python实例. MacPorts将所有Python软件包安装到其自己的Python解释器中.因此,如果您使用以下命令安装了Python 2.7版本:

Since you show path /opt/local/lib, I assume you are using MacPorts since this is its default installation path. If you are not able to import a MacPorts-installed Python package, chances are you are using the wrong Python instance. MacPorts installs all Python packages to its own Python interpreter. So, if you installed the Python 2.7 version with:

sudo port install py27-graph-tool

如果尚未安装,MacPorts也将在/opt/local/bin中安装它自己的python2.7.尝试运行该文件并在那里进行导入.

MacPorts would also have installed, if not installed already, its own python2.7 in /opt/local/bin. Try running that instead and doing the import there.

/opt/local/bin/python2.7

如果尚未将/opt/local/bin添加到外壳启动文件(如~/.profile)中的外壳路径中,则不必总是键入/opt/local/bin.

If you haven't already, you should add /opt/local/bin to your shell PATH in a shell startup file, like ~/.profile, so you don't need to always type /opt/local/bin.

这篇关于永久添加到MAC上的DYLD_LIBRARY_PATH会导致X11错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆