Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg_resources.DistributionNotFound: The 'PyInstaller' distribution was not found and is required by the application #5806

Closed
mx5dev opened this issue May 6, 2021 · 2 comments

Comments

@mx5dev
Copy link

mx5dev commented May 6, 2021

I'm trying to get an exe file from a python software composed by multiple python scripts.

Here my env setup:

  • Windows 10 x64
  • Python 3.7.3
  • PyInstaller 5.0.dev0

Folder hierarchy:

folder A
    folder B
        main python script 
        folder hooks
            hook-configuration.py
    folder C
        python files with definitions called in the main python script

Before to write the question I've read the issue #4651 and I wrote my hook file called `hook-configuration.py., with the following content:

from PyInstaller.utils.hooks import collect_data_files
from PyInstaller.utils.hooks import collect_all

datas, binaries, hiddenimports = collect_all('configuration')

hiddenimports = ['configuration.model.config_model',
                 'configuration.model.component',
                 'configuration.model.shadow_mode',
                 'configuration.model.opcua_server',
                 'configuration.model.environment',
                 'configuration.model.component_group',
                 'configuration.model.deployment',
                 'configuration.model.deployment',
                 'configuration.model.controls',
                 'configuration.ixl_parser.parsed_document',
                 'configuration.ixl_parser.parsed_xml_document',
                'configuration.ixl_parser.ccs_properties',
                'configuration.model.tarball_target']


datas = collect_data_files('ConfigModel')
datas = collect_data_files('Component')
datas = collect_data_files('IxlComponent')
datas = collect_data_files('ModbusComponent')
datas = collect_data_files('EbisatComponent')
datas = collect_data_files('S7CommComponent')
datas = collect_data_files('FffisEgComponent')
datas = collect_data_files('TransformerProducerComponent')
datas = collect_data_files('TransformerWorkerComponent')
datas = collect_data_files('C85IpComponent')
datas = collect_data_files('ShadowModeComponent')
datas = collect_data_files('OpcuaServer')
datas = collect_data_files('EnvironmentElement')
datas = collect_data_files('ComponentGroup')
datas = collect_data_files('Deployment')
datas = collect_data_files('DeploymentSchema')
datas = collect_data_files('DataCentre')
datas = collect_data_files('DataCentreDeployment')
datas = collect_data_files('ClusterNode')
datas = collect_data_files('DerivedIndication')
datas = collect_data_files('UnmappedIndication')
datas = collect_data_files('RtuDataControl')
datas = collect_data_files('ParsedDocument')
datas = collect_data_files('ParsingFailedException')
datas = collect_data_files('ParsedXmlDocument')
datas = collect_data_files('ParseExtraFiles')
datas = collect_data_files('CcsProperties')
datas = collect_data_files('TarballExportTarget')

The entrypoint of the program is a script which has the following import:

import argparse
import logging
import os
import sys
import time
from copy import deepcopy
from lxml import etree as ET
from configuration.model.config_model import ConfigModel  # pylint: disable=import-error
from configuration.model.component import Component, IxlComponent, ModbusComponent, EbisatComponent, S7CommComponent, FffisEgComponent # pylint: disable=import-error
from configuration.model.component import TransformerProducerComponent, TransformerWorkerComponent, C85IpComponent # pylint: disable=import-error
from configuration.model.shadow_mode import ShadowModeComponent # pylint: disable=import-error
from configuration.model.opcua_server import OpcuaServer # pylint: disable=import-error
from configuration.model.environment import EnvironmentElement # pylint: disable=import-error
from configuration.model.component_group import ComponentGroup # pylint: disable=import-error
from configuration.model.deployment import Deployment, DeploymentSchema, DataCentre, DataCentreDeployment, ClusterNode # pylint: disable=import-error
from configuration.model.indications import DerivedIndication, UnmappedIndication # pylint: disable=import-error
from configuration.model.controls import RtuDataControl # pylint: disable=import-error
from configuration.ixl_parser.parsed_document import ParsedDocument, ParsingFailedException # pylint: disable=import-error
from configuration.ixl_parser.parsed_xml_document import ParsedXmlDocument, ParseExtraFiles, RtuData # pylint: disable=import-error
from configuration.ixl_parser.ccs_properties import CcsProperties # pylint: disable=import-error
from collections import defaultdict # pylint: disable=import-error

I also tried to launch pyInstaller using -F and --debug=all arguments (found it in #4809) but it doesn't work.

Stacktrace / full error message

Traceback (most recent call last):
File "hooks\hook-configuration.py", line 1, in <module>
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "c:\python\lib\site-packages\PyInstaller\__init__.py", line 55, in <module>
__version__ = pkg_resources.get_distribution('PyInstaller').version
File "c:\python\lib\site-packages\pkg_resources\__init__.py", line 466, in get_distribution
dist = get_provider(dist)
File "c:\python\lib\site-packages\pkg_resources\__init__.py", line 342, in get_provider
return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
File "c:\python\lib\site-packages\pkg_resources\__init__.py", line 886, in require
needed = self.resolve(parse_requirements(requirements))
File "c:\python\lib\site-packages\pkg_resources\__init__.py", line 772, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'PyInstaller' distribution was not found and is required by the application
[7260] Failed to execute script hook-configuration
@mx5dev
Copy link
Author

mx5dev commented May 6, 2021

The pyInstaller command is:

pyinstaller --noconfirm --onefile --console --add-data "folderC" --additional-hooks-dir "hooks" --runtime-hook "hook-configuration.py" --hidden-import "appdirs" --hidden-import "packaging" --hidden-import "packaging.version" --hidden-import "packaging.specifiers" --hidden-import "packaging.requirements"  "main.py"

@rokm
Copy link
Member

rokm commented May 6, 2021

  1. The hook is incorrect; either you do collect_all(x) (which internally calls collect_data_files(x), collect_submodules(x), and collect_dynamic_libraries(x) or you manually specify hiddenimports and partially collect datas. Even so, you should be apending to datas, not overwriting it with each call. And collect_data_files() expects package name, not names of classes from your modules...

  2. --runtime-hook "hook-configuration.py" your hook is not a run-time one, so this is also incorrect.

  3. pkg_resources.DistributionNotFound: The 'PyInstaller' distribution was not found and is required by the application

The application should not require PyInstaller anywhere, so either this is caused by incorrect --runtime-hook (see point 2) or your application is importing PyInstaller somewhere, which it should not.

@pyinstaller pyinstaller locked and limited conversation to collaborators May 6, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants