我在按照这个教程学习如何将我的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)
然而,VSCode给我一个错误提示:模块'sys'没有'_MEIPASS'成员。我已经在网上搜索了很长时间,仍然不知道如何解决。