导入错误:需要“platformdirs”包

问题描述 投票:0回答:1

希望你能解决我的问题! 我想使用 pyinstaller(6.5.0 - 最新版本)来编译我的 app.py 代码(在 annaconda 虚拟环境下),但我收到以下错误消息:

File "Lib\site-packages\PyInstaller\hooks\rthooks\pyi_rth_pkgres.py", line 158, in <module>
File "Lib\site-packages\PyInstaller\hooks\rthooks\pyi_rth_pkgres.py", line 36, in _pyi_rthook
File "PyInstaller\loader\pyimod02_importers.py", line 419, in exec_module
File "pkg_resources\__init__.py", line 74, in <module>
File "pkg_resources\extern\__init__.py", line 52, in create_module
File "pkg_resources\extern\__init__.py", line 44, in load_module
ImportError: The 'platformdirs' package is required; normally this is bundled with this package so if you get this warning, consult the packager of your distribution.
[21944] Failed to execute script 'pyi_rth_pkgres' due to unhandled exception!

我使用的是 Windows 10。 感谢您的帮助,非常感谢!

我尝试使用隐藏导入添加 platformdirs 甚至 pkg_resources 但没有成功...

pyinstaller importerror
1个回答
0
投票

pyinstaller --onefile --paths=path\to\your\env\Lib\site-packages --hidden-import=platformdirs app.py
这对我有用

© www.soinside.com 2019 - 2024. All rights reserved.