Search code examples
pythonsubprocesscygwin

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. I want to execute everything on Cygwin.

The following is my Python function doing that:

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
  • I ran other commands (cd, pwd,...) with said python script, again without a 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.

I hope someone can help me, I'm very new to this topic.

EDIT: I also discovered, that the command "ls" does not work. "cd", "pwd" do work.


Solution

  • Solved: I fixed it with adding C:/cygwin64/bin to the Path variable.