Show native import attempts in python3
Question: I wrote a Python 3 extension module in C but cannot seem to get Python to
import it.

Is there any way to let Python print out which shared libraries (.so on Linux)
it tries to load and why it fails?

Sadly all the docs I read don't really help since none describes the native
import procedure in a concise way.

What I tried is:

    
    
    ctypes.CDLL("libmydep1.so")
    ctypes.CDLL("libmydep2.so")
    
    try:
        import my_main
        print("Load python")
    except:
        ctypes.CDLL("libmylib.so")
        print("Load shared object")
    

Which always prints `Load shared object`.

`libmylib.so` contains the python entry point but loading it as Python 3
extension does not seem to work, although loading as a shared library does.

**EDIT:**

Python does not honor linux conventions. So for a lib you do not name it
`libmylib.so` but `mylib.so`.

Even worse, it only loads `my_main`, when the so is named `my_main.so`. So
annoying.


Answer: Try to look at `/proc/<pid>/maps` directory.

Or try to use `lsof -p <PID>` command in shell.

Source of answer is [this forum](http://www.unix.com/programming/34498-how-
view-loaded-shared-libraries-running-processes-linux.html). lsof [man
page](http://linux.die.net/man/8/lsof). See also [this
answer](http://stackoverflow.com/questions/5103443/how-to-check-what-shared-
library-is-loaded-at-run-time).

