简体   繁体   English

python 子进程 - cygwin 调用 - 加载共享库时出错

[英]python subprocess - cygwin call - error while loading shared libraries

I am trying to run a.exe file on Windows 10, by calling it inside of a Python 3.8 script with subprocess.我正在尝试在 Windows 10 上运行 a.exe 文件,方法是在带有子进程的 Python 3.8 脚本中调用它。 I want to execute everything on Cygwin.我想在 Cygwin 上执行一切。

The following is my Python function doing that:以下是我的 Python function 这样做:

os.chdir(r"c:\cygwin64\bin")
cmd = ["bash", "-c", 'cd "C:/Users/usr/file"; ./myexefile']
subprocess.call(cmd)

This will give me the error这会给我错误

C:/Users/usr/file/myexefile.exe: error while loading shared libraries: ?: cannot open shared object file: No such file or directory

While I was trying to figure out, what is the problem,当我试图弄清楚问题是什么时,

  • I executed the file on the cygwin shell directly, without a problem我直接在cygwin shell上执行文件,没有问题
  • I ran other commands (cd, pwd,...) with said python script, again without a problem.我用所说的 python 脚本运行了其他命令(cd、pwd、...),同样没有问题。

I read some solutions of that specific error, in other contexts, saying one is supposed to change path variables, but as the function call works within Cygwin, I don't think this works.我在其他情况下阅读了该特定错误的一些解决方案,说一个应该更改路径变量,但是由于 function 调用在 Cygwin 中有效,我认为这不起作用。

I hope someone can help me, I'm very new to this topic.我希望有人可以帮助我,我对这个话题很陌生。

EDIT: I also discovered, that the command "ls" does not work.编辑:我还发现,命令“ls”不起作用。 "cd", "pwd" do work. “cd”、“pwd”确实有效。

This looks like a Windows python trying to run a Cygwin shell这看起来像 Windows python 试图运行 Cygwin shell

os.chdir(r"c:\cygwin64\bin")
cmd = ["bash", "-c", 'cd "C:/Users/usr/file"; ./myexefile']
subprocess.call(cmd)

assuming that myexefile is a Cygwin program, as the bash is not run with login option the PATH is not correctly set and the needed shared lib are not found.假设myexefile是 Cygwin 程序,因为 bash 未使用登录选项运行,因此未正确设置 PATH 并且找不到所需的共享库。

If you need to know which DLLs are needed for a program or shared lib:如果您需要知道程序或共享库需要哪些 DLL:

$ objdump -x octave-5.2.0.exe |grep "DLL Name:"
        DLL Name: cygwin1.dll
        DLL Name: cygX11-6.dll
        DLL Name: cyggcc_s-seh-1.dll
        DLL Name: cygstdc++-6.dll
        DLL Name: KERNEL32.dll

Solved: I fixed it with adding C:/cygwin64/bin to the Path variable.解决:我通过将C:/cygwin64/bin添加到Path变量来修复它。

暂无
暂无

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

相关问题 从python调用Cygwin失败,并出现以下错误:加载共享库时出错:?:无法打开共享对象文件:没有此类文件或目录 - Calling Cygwin from python fails with: error while loading shared libraries: ?: cannot open shared object file: No such file or directory 使用pyinstaller将python脚本转换为可执行文件后,我得到:加载共享库时出错...权限被拒绝 - After converting python script to executable with pyinstaller I get: error while loading shared libraries… Permission denied Python3.7:加载共享库时出错:libpython3.7m.so.1.0 - Python3.7: error while loading shared libraries: libpython3.7m.so.1.0 python:加载共享库时出错:libpython3.4m.so.1.0:无法打开共享对象文件:没有这样的文件或目录 - python: error while loading shared libraries: libpython3.4m.so.1.0: cannot open shared object file: No such file or directory 加载共享库时出现 Python 错误:libpython3.5m.so.1.0:无法打开共享对象文件:没有这样的文件或目录 - Python error while loading shared libraries: libpython3.5m.so.1.0: cannot open shared object file: No such file or directory ./python:加载共享库时出错:libssl.so.1.1:无法打开共享对象文件:没有这样的文件或目录 - ./python: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory Bitnami - /opt/bitnami/python/bin/.python2.7.bin:加载共享库时出错:libreadline.so.5 - Bitnami - /opt/bitnami/python/bin/.python2.7.bin: error while loading shared libraries: libreadline.so.5 docker-compose “/usr/local/bin/python: error while loading shared libraries: libpython3.8.so.1.0:”时出错 - Error when docker-compose “/usr/local/bin/python: error while loading shared libraries: libpython3.8.so.1.0: ” PySide6:加载共享库时出错:libQt6DesignerComponents.so.6:无法打开共享 object 文件 - PySide6: error while loading shared libraries: libQt6DesignerComponents.so.6: cannot open shared object file 使用python subprocess.call()函数时出现程序错误 - Program error while using python subprocess.call() function
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM