python执行脚本时依赖什么?
尴尬的场景是
我正在开发一个 python 包,并且想使用一个不是我自己编写的外部包作为依赖项。
由于外部包非常复杂,它还附带了各种多余的软件,例如它自己的 bash 或 python 可执行文件。当然,我不想使用 bash 或提供的 python 可执行文件,而是使用我自己的 IDE 设置。
因此,我开始检查交付的 bash 的环境变量,例如 PATH、PYTHONPATH 或 LD_LIBRARAY_PATH (外部包依赖于编译的共享对象) )。
设置这些环境变量后,我尝试从 IDE 中运行一个简单的“Hello World”脚本,但没有成功(这就是我在这里发帖的原因^^)。另一方面,如果我从交付的 bash 中运行相同的脚本,它运行时不会出现问题。
问题
- python 或者更复杂的 python 代码依赖什么样的依赖项?
- 有没有办法检查为什么从两个不同环境执行的脚本表现不同?
我从 IDE 中运行脚本的问题是包中的错误,而不是某些无法找到共享对象或无法加载模块...之类的问题。但为什么它的行为不同呢?
除了环境变量之外,还有哪些问题可以使两个不同的 python 可执行文件运行完全相同?
The awkward scenario
I am developing a python package and would like to make use of an external package, that was not written by myself, as a dependency.
Since the external package is quite complex it also comes with all kinds of surplus software like its own bash or python executable. Naturally I do not want to use the bash or the delivered python executable but rather use my own IDE setup.
I therefore started to check the environment variables of the delivered bash like the PATH, PYTHONPATH or the LD_LIBRARAY_PATH (the external package relies on compiled shared objects).
After setting those environment variables I tried to run a simple "Hello World" script from within my IDE but did not succeed (which is why I am posting here^^). On the other hand if I run the same script from within the delivered bash it runs without a problem.
Questions
- What kind of dependencies does python, or even more complex, python code rely on?
- Is there a way to check why the script executed from two different environments behaves differently?
The problem I have running the script from within my IDE is a bug in the package and not some cannot find shared object or unable to load module ... or something. But why does it behave differently?
What other issues than environment variables might there be to make two different python executables run exactly the same?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里列出了 Python 使用的所有环境变量: Python 环境变量
确保您的 Python 解释器的版本与外部解释器的版本相同。
All environment variables used by Python are listed here: Python environment variables
Ensure that your Python interpreter has the same version than the external one .