Python使用哪个包?

dot*_*hen 6 python package

我看到可以安装几个版本的Python包:

$ locate signals.py | grep python
/usr/lib/pymodules/python2.7/zim/signals.py
/usr/lib/pymodules/python2.7/zim/signals.pyc
/usr/lib/python2.7/dist-packages/bzrlib/smart/signals.py
/usr/lib/python2.7/dist-packages/bzrlib/smart/signals.pyc
/usr/lib/python2.7/unittest/signals.py
/usr/lib/python2.7/unittest/signals.pyc
/usr/lib/python3.2/unittest/signals.py
Run Code Online (Sandbox Code Playgroud)

我如何检查应用程序使用的软件包版本(即哪个文件,而不是哪个版本号)?忽略明显的"Zim将使用包/usr/lib/pymodules/python2.7/zim/signals.py"是否可以查看哪个文件用于特定的Python包?

有些软件包可以崩溃并查看回溯.但是,我不认为这是最好的方法!

Len*_*bro 8

__file__属性将告诉您:

>>> from unittest import signals
>>> signals.__file__
'/usr/lib/python2.7/unittest/signals.pyc'
Run Code Online (Sandbox Code Playgroud)

.pyc是编译文件,所以你实际上在寻找/usr/lib/python2.7/unittest/signals.py文件的文件.