所以我正在遵循本教程,了解如何将 python 项目转换为可执行文件:https://dev.to/eshleron/how-to-convert-py-to-exe-step-by-step-guide-3cfi
我需要编写这个函数:
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)
Run Code Online (Sandbox Code Playgroud)
但是 VSCode 给了我这个错误:模块“sys”没有“_MEIPASS”成员。在网上查了好久还是不知道怎么解决。
python ×1