Skip to content
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

pyinstaller result failed with schwifty #5390

Closed
zdenop opened this issue Dec 14, 2020 · 6 comments
Closed

pyinstaller result failed with schwifty #5390

zdenop opened this issue Dec 14, 2020 · 6 comments

Comments

@zdenop
Copy link

zdenop commented Dec 14, 2020

-- schwifty_test.py --

from schwifty import IBAN
iban = IBAN('DE89 3704 0044 0532 0130 00')
print(iban.bic)

-- schwifty_test.spec --

ffrom PyInstaller.utils.hooks import copy_metadata, collect_data_files


block_cipher = None


a = Analysis(['schwifty_test.py'],
             pathex=[],
             datas = copy_metadata("pycountry") + collect_data_files('pycountry'),
			 binaries=[],
             hiddenimports=[],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher,
             noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          a.binaries,
          a.zipfiles,
          a.datas, 
		  [], name='schwifty_test',
          debug=False,
          bootloader_ignore_signals=False,
          strip=False,
          upx=False,
          upx_exclude=[],
          runtime_tmpdir=None,
          console=True )

Build with pyinstaller --clean schwifty_test.spec. Running dist\schwifty_test.exe finished with:

Traceback (most recent call last):
  File "schwifty_test.py", line 2, in <module>
    from schwifty import IBAN
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "C:\Program Files\Python38\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
    exec(bytecode, module.__dict__)
  File "schwifty\__init__.py", line 3, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "C:\Program Files\Python38\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
    exec(bytecode, module.__dict__)
  File "schwifty\bic.py", line 288, in <module>
  File "schwifty\registry.py", line 49, in build_index
  File "schwifty\registry.py", line 20, in get
  File "pkg_resources\__init__.py", line 1146, in resource_listdir
  File "pkg_resources\__init__.py", line 1424, in resource_listdir
  File "pkg_resources\__init__.py", line 1466, in _listdir
NotImplementedError: Can't perform this operation for unregistered loader type
[9552] Failed to execute script schwifty_test

First error was related to pycountry that is used by schwifty. This I tried to fix in spec file with examples from issue tracker.
Not sure how to fix error posted above...

@rokm
Copy link
Member

rokm commented Dec 14, 2020

NotImplementedError: Can't perform this operation for unregistered loader type

This one is due to missing support for pkg_resources provider (#4881), and should be fixed once #5284 is merged.

You can try using pyinstaller branch from #5284 (i.e., pip install https://github.com/rokm/pyinstaller/archive/pkg-resources.zip). Alternatively, you could modify schwifty\registry.py to use regular os functions (listdir, etc.) instead of resource_listdir and resource_filename.

In either case, you will probably also need to add a collect_data_files for schwifty, in order to have the JSONs in bank_registry and iban_registry collected.

@rokm
Copy link
Member

rokm commented Dec 14, 2020

@zdenop The alternative "solution" was meant as a temporary work-around in your installed copy of schwifty, not as something to be done upstream.

@MohammedAlawami
Copy link

@rokm I'm having the same issue with investpy package,
I tried installing the branch from #5284 but that didn't solve my issue, I got FileNotFoundError: ERR#0075: commodities file not found or errored

@bwoodsend
Copy link
Member

@MohammedAlawami That appears to have nothing to do with this issue. Open a new one.

@rokm
Copy link
Member

rokm commented Mar 20, 2021

You probably didn't collect data files for investpy, which are located in its resources folder.

@rokm
Copy link
Member

rokm commented Mar 23, 2021

#5284, which fixes this issue, has been merged.

@rokm rokm closed this as completed Mar 23, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants