哪些python变量位于libpython[M].[M].so或pythonMm.dll?

2021-11-29 23:06:13 发布

您现在位置:Python中文网/ 问答频道 /正文

在python2和python3中,有没有找到python共享对象(或dll)的路径的真正方法?你知道吗

$ for x in 2 3;do python$x -m sysconfig |grep -w LDLIBRARY; done
LDLIBRARY = "libpython2.7.so" 
LDLIBRARY = "libpython3.5m.so"

$ for x in 2 3;do python$x -m sysconfig |grep -w LIBDIR; done
LIBDIR = "/usr/local/lib"
LIBDIR = "/usr/lib"

$ ldd `which python2`
[...]
libpython2.7.so.1.0 => /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0
[...]

$ ls -l /usr/local/lib/libpython*
-r-xr-xr-x 1 root root 15029380 Sep 14 15:50 /usr/local/lib/libpython2.7.a
lrwxrwxrwx 1 root root       19 Sep 15 15:10 /usr/local/lib/libpython2.7.so -> libpython2.7.so.1.0
-r-xr-xr-x 1 root root  8032648 Sep 15 15:10 /usr/local/lib/libpython2.7.so.1.0

$ ls -l /usr/lib/libpython*
ls: cannot access '/usr/lib/libpython*': No such file or directory