1

I created a python executable by using pyinstaller, but the jira module imported to my .py script is not present when I execute executable

Traceback (most recent call last):

 File "myfile.py", line 7, in <module>
 File "<frozen importlib._bootstrap>", line 969, in _find_and_load
 File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
 File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
 File "<frozen importlib._bootstrap>", line 634, in      _load_backward_compatible
 File "c:\users\rajivkum\appdata\local\continuum\anaconda3\lib\site-packages\Py
 Installer\loader\pyimod03_importers.py", line 389, in load_module
 exec(bytecode, module.__dict__)
 File "site-packages\jira\__init__.py", line 6, in <module>
 File "site-packages\setuptools-18.5-py3.5.egg\pkg_resources\__init__.py", line
 558, in get_distribution
 File "site-packages\setuptools-18.5-py3.5.egg\pkg_resources\__init__.py", line
 438, in get_provider
 File "site-packages\setuptools-18.5-py3.5.egg\pkg_resources\__init__.py", line
 959, in require
 File "site-packages\setuptools-18.5-py3.5.egg\pkg_resources\__init__.py", line
 846, in resolve
 pkg_resources.DistributionNotFound: The 'jira' distribution was not found and is
 required by the application
RajivKumar
  • 65
  • 8

1 Answers1

2

PyInstaller (and also cx_Freeze and Py2exe) have problems with including jira. What you have to do is to create, preferably in the same directory as your project a "hook file" for PyInstaller. Name the file "hook-jira.py". Content of the file should look like that:

from PyInstaller.utils.hooks import copy_metadata

datas = copy_metadata('jira')

This will assure that PyInstaller will include jira. Then, you just have to run in the directory where myfile.py and hook file are located:

PyInstaller myfile.py --additional-hooks-dir=.

to tell PyInstaller that it should look for hook files in the current directory. This should solve the problem.