gpt4 book ai didi

python - Pyinstaller/Django - pkg_resources.DistributionNotFound : The 'django-omnibus' distribution was not found

转载 作者:太空宇宙 更新时间:2023-11-04 10:16:56 26 4
gpt4 key购买 nike

我正在尝试为使用 django-omnibus 的 django 网站创建安装程序模块。

我的 Pyinstaller 命令:

pyinstaller --name djangosite manage.py

Pyinstaller 命令运行完成。

尝试使用

运行网络服务器
djangosite.exe runserver localhost:8000

我收到以下错误:

Traceback (most recent call last):
File "<string>", line 10, in <module>
File "django\core\management\__init__.py", line 338, in execute_from_command_line
File "django\core\management\__init__.py", line 312, in execute
File "django\__init__.py", line 18, in setup
File "django\apps\registry.py", line 85, in populate
File "django\apps\config.py", line 86, in create
File "importlib\__init__.py", line 37, in import_module
File "c:\users\USERNAME\appdata\local\temp\pip-build-vxcefe\pyinstaller\PyInstaller\loader\pyimod03_importers.py", line 389, in load_module
File "omnibus\__init__.py", line 3, in <module>
File "pkg_resources\__init__.py", line 561, in get_distribution
File "pkg_resources\__init__.py", line 441, in get_provider
File "pkg_resources\__init__.py", line 962, in require
File "pkg_resources\__init__.py", line 849, in resolve
pkg_resources.DistributionNotFound: The 'django-omnibus' distribution was not found and is required by the application manage returned -1

如果我删除所有 django-omnibus 代码,该站点可以正常工作(显然我的 websocket 功能除外)。有任何想法吗?谢谢。

最佳答案

我需要为 django-omnibus 添加一个 hook.py 文件,并将 --additional-hooks-dir=. 标志添加到 pyinstaller 命令。

钩子(Hook)omnibus.py

from PyInstaller.utils.hooks import copy_metadata, collect_data_files

datas = copy_metadata('django-omnibus')
datas += collect_data_files('omnibus')

类似的答案在这里: https://github.com/pyinstaller/pyinstaller/issues/1713

关于python - Pyinstaller/Django - pkg_resources.DistributionNotFound : The 'django-omnibus' distribution was not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34775667/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com