[英]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 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.