Permission denied on dl.open() with ipython but not with python

前端 未结 3 2043
梦谈多话
梦谈多话 2021-02-19 11:16

My initial goal is to open a dll file on Cygwin using ctypes. However I found some issues with it. I dug up to sys.dl which returns an unk

3条回答
  •  爱一瞬间的悲伤
    2021-02-19 11:34

    More ideas:

    • Check that the user accessing the DLL is the same. You do that like this:

      import getpass

      print(getpass.getuser())

    • Check what's the current process actually doing. I haven't used cygwin but in the linux shell the executable strace should show you this. Usage: get the PID of your current process: import os; os.getpid() After this, you can use (from outside the python/ipython console the command strace -p -e file. After this setup, you can try to load your DLL.

    Remarks: the -e file flag should be written exactly like that. The word file tells strace to report all file operations that the process makes. If no differences occur when running on python/ ipython, you can try dropping the -e file flag. Then you will see all system calls that the process makes. I haven't worked on windows like that, so this might not work at all there, but on linux at least, this should report to you everything that the process did. You could see there at least all the files that got opened, but more interesting things could be found there as well. If the outputs are identical, then the problem can be debugged further in python/ ipython. This would require basically what @Doug Blank suggested, but I'd also recommend investigating every name (variable) that gets touched. The self, _dlopen and mode names also sound like they might contain useful information.

    Otherwise, do a dir(self) and dir(_dlopen) to see what other properties you could find there that might have gotten modified by IPYthon.

    Try these first, and after that we can help you dig further.

提交回复
热议问题