简体   繁体   English

我可以从Python设置@executable_path吗

[英]Can I set @executable_path from Python

I have an application written in Python that uses Ogre3D via a C++ wrapper module. 我有一个用Python编写的应用程序,它通过C ++包装器模块使用Ogre3D。 When attempting to run my application 尝试运行我的应用程序时

python /path/to/myapp.py

I get the error 我得到错误

dlopen(./MyOgreWrapper.so, 2): Library not loaded: @executable_path/../Frameworks/Ogre.framework/Versions/1.9.0/Ogre Referenced from: /path/to/MyOgreWrapper.so Reason: image not found dlopen(./ MyOgreWrapper.so,2):库未加载:@executable_path /../ Frameworks / Ogre.framework / Versions / 1.9.0 / Ogre引用自:/path/to/MyOgreWrapper.so原因:找不到图像

I am running it from the directory where MyOgreWrapper.so is located so that MyOgreWrapper.so can be found by Python. 我从MyOgreWrapper.so所在的目录中运行它,以便可以通过Python找到MyOgreWrapper.so。 Ogre.framework is located in ../Frameworks relative to the location of MyOgreWrapper.so. Ogre.framework相对于MyOgreWrapper.so的位置位于../Frameworks中。

$otool -l MyOgreWrapper.so
MyOgreWrapper.so:
@rpath/MyOgreWrapper.so (compatibility version 0.0.0, current version 0.0.0)
@executable_path/../Frameworks/Ogre.framework/Versions/1.9.0/Ogre (compatibility version 1.9.0, current version 1.9.0)
...

I suspect that this happens because @executable_path is set to the path of the python executable. 我怀疑这是因为@executable_path设置为python可执行文件的路径。

Is there a way to set up the environment from Python so that @executable_path is the current directory? 有没有一种方法可以从Python设置环境,以便@executable_path是当前目录?

(I know that it will all work if I change the path for Ogre in MyOgreWrapper.so and a few other dependencies to @loader_path but that is not how it comes out of the box and I'd rather not have to do that.) (我知道,如果我在MyOgreWrapper.so中将Ogre的路径以及其他一些依赖项更改为@loader_path,这一切都会起作用,但这不是开箱即用的方式,我宁愿不必这样做。)

No, there's no way to control @executable_path from within the executable. 不,无法从可执行文件内控制@executable_path @executable_path is resolved by dyld , the dynamic loader, and it uses the path of the executable that it loaded. @executable_path由动态加载程序dyld解析,它使用它加载的可执行文件的路径。 It's fixed for any given executable. 它对于任何给定的可执行文件都是固定的。

Also, if you could change it, that would probably break other stuff that the process attempts to load. 另外,如果可以更改它,则可能会破坏该进程尝试加载的其他内容。

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

相关问题 dyld:库未加载:@executable_path/../.Python - dyld: Library not loaded: @executable_path/../.Python 弃用警告:executable_path 已弃用 selenium python - DeprecationWarning: executable_path has been deprecated selenium python SeleniumLibrary 不接受 executable_path - SeleniumLibrary doesn't accept executable_path SyntaxError:IPython中的execute_path语法无效 - SyntaxError: invalid syntax with executable_path in ipython Selenium 服务忽略可执行文件路径? - Selenium Service ignoring executable_path? macOS 11.6/Xcode 13 上的诗歌安装失败:dyld:未加载库:@executable_path/../Python3 - poetry install fails on macOS 11.6/Xcode 13: dyld: Library not loaded: @executable_path/../Python3 TypeError: __init__() 使用 Selenium 到 Python 获得了参数“executable_path”的多个值 - TypeError: __init__() got multiple values for argument 'executable_path' using Selenium through Python AWS SAM CLI 全新安装引发错误 - dyld:未加载库:@executable_path/../.Python - AWS SAM CLI Fresh install throws error - dyld: Library not loaded: @executable_path/../.Python 如何在Visual Studio Code中为可执行文件和库设置python环境路径 - How can I set up a python environment path for executable and libraries in Visual Studio Code 我可以在python脚本中找到运行python脚本的可执行文件的路径吗? - Can I find the path of the executable running a python script from within the python script?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM