How to get path of a python module ( not sys.executable )

前端 未结 2 860
旧时难觅i
旧时难觅i 2021-02-20 14:51

I need to get Path for PyQt library in python program. Program is run as a script from another application, therefore my

sys.executable = \'D:/program files/vis         


        
2条回答
  •  余生分开走
    2021-02-20 15:41

    you can try to load the module and after check for it's __file__ attribute to get the path of the .pyc file.

    for example like this:

    import MODULE, os
    path = os.path.dirname(MODULE.__file__)
    

    Regards, HTH!

提交回复
热议问题