作用:
用pyinstaller打包生成的exe文件,在运行时动态生成依赖文件,sys._MEIPASS就是这些依赖文件所在文件夹的路径
问题:
仅在exe运行时有效,IDE运行时报错
AttributeError: module 'sys' has no attribute '_MEIPASS'
使用:
base_path = getattr(sys,'_MEIPASS',os.path.dirname(os.path.abspath(__file__)))
sys._MEIPASS
# IDE执行报错
# pyinstaller -F 文件后执行正常