您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

Python-使用PyInstaller捆绑数据文件(--onefile)

Python-使用PyInstaller捆绑数据文件(--onefile)

较新版本的PyInstaller不再设置该env变量,因此Shish的出色答案将不起作用。现在,路径设置为sys._MEIPASS

def resource_path(relative_path):
    """ Get absolute path to resource, works for dev and for PyInstaller """
    try:
        # PyInstaller creates a temp folder and stores path in _MEIPASS
        base_path = sys._MEIPASS
    except Exception:
        base_path = os.path.abspath(".")

    return os.path.join(base_path, relative_path)
python 2022/1/1 18:24:42 有515人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶