Pyinstaller / Django - pkg_resources.DistributionNotFound:未找到'django-omnibus'发行版

时间:2016-01-13 19:44:24

标签: python django pyinstaller

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

我的Pyinstaller命令:

pyinstaller --name djangosite manage.py

Pyinstaller命令运行完成。

尝试使用

运行Web服务器
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功能除外)。有任何想法吗?感谢。

2 个答案:

答案 0 :(得分:2)

我需要为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

答案 1 :(得分:1)

我知道这是一个迟到的回复,但我在 django-user-accounts - pkg_resources.DistributionNotFound: The 'django-user-accounts' distribution was not found

上遇到了类似的问题

我在搜索修复时被定向到这里。我通过以下添加到settings.py解决了这个问题 - 希望能帮到其他人。

INSTALLED_APPS = [
    ...
    'django.contrib.sites',
    ...
]