How to fix error with pyinstaller after compilation in exe

HsKSD

I compiled a Python script into an exe file, but after opening the exe, the console opens and an error occurs, then the console immediately closes. Perhaps this is due to the fact that I am using downloaded libraries (web3, bs4, hdwallet, bip_utils)

Traceback (most recent call last):
  File "CryptoWallet.py", line 11, in <module>
  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 "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
  File "bip_utils\__init__.py", line 21, in <module>
  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 "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
  File "bip_utils\wif\__init__.py", line 1, in <module>
  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 "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
  File "bip_utils\wif\wif.py", line 27, in <module>
  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 "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
  File "bip_utils\ecc\__init__.py", line 2, in <module>
  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 "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
  File "bip_utils\ecc\elliptic_curve_getter.py", line 31, in <module>
  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 "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
  File "bip_utils\ecc\secp256k1.py", line 39, in <module>
  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 "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
  File "bip_utils\ecc\secp256k1_keys_coincurve.py", line 25, in <module>
  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 "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
  File "coincurve\__init__.py", line 1, in <module>
  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 "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
  File "coincurve\context.py", line 4, in <module>
  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 "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
  File "coincurve\flags.py", line 1, in <module>
  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 "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
  File "coincurve\_libsecp256k1.py", line 239, in <module>
  File "cffi\api.py", line 150, in dlopen
  File "cffi\api.py", line 832, in _make_ffi_library
  File "cffi\api.py", line 827, in _load_backend_lib
OSError: cannot load library 'C:\CryptoWallet\dist\CryptoWallet\coincurve\libsecp256k1.dll': error 0x7e.  Additionally, ctypes.util.find_library() did not manage to locate a library called 'C:\\\CryptoWallet\\dist\\CryptoWallet\\coincurve\\libsecp256k1.dll'
[21180] Failed to execute script 'CryptoWallet' due to unhandled exception!
dub-dub

It seems like you need to copy the files that your project uses in to the exe. To do this you need to add-data when running pyinstaller. You can use pyinstaller spec files to configure the settings of your compilation.

Here is a example of spec file (you need to modify it for your use):

a = Analysis(['C:\\path\\to\\your\\main\\py file.py'],
             pathex=['C:\\path\\to\\search\\for\\imports'],  
             binaries=[],
             datas=[('C:\\Users\\username\\AppData\\Local\\Programs\\Python\\Python38\\Lib\\site-packages\\package\\xxxx\\yyyyy\\*', '.\\package\\xxxx\\yyyyy'),
             ('C:\\Users\\username\\AppData\\Local\\Programs\\Python\\Python38\\Lib\\site-packages\\package2\\zzz\\*', '.\\package2\\zzz'),
             ],
             hiddenimports=["a_package"], #A list of module names (relative or absolute) that should be part of the bundled app
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=None,
             noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
             cipher=None)
exe = EXE(pyz,
          a.scripts,
          a.binaries,
          a.zipfiles,
          a.datas,
          [],
          name='nameOfExe',
          debug=False,
          bootloader_ignore_signals=False,
          strip=False,
          upx=True,
          upx_exclude=[],
          runtime_tmpdir=None,
          console=False,
          icon='icon.ico') # specify icon

You can check other parameters and what they do from Pyinstaller docs.

This file can be run using:

python -m PyInstaller -F main.spec --clean

Collected from the Internet

Please contact javaer1[email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to fix illegal start of expression compilation error?

How can I fix icon of python executable after using pyinstaller?

PyInstaller exe gives cython error

How to fix Error: Unresolved compilation problems: Syntax error on token "rs"

How to fix "WARNING: Hidden import "pygame._view" not found!" when converting .py to .exe using PyInstaller?

after generated .exe using pyinstaller it give me error (no module named exchangelib)

I get error "No module named 'pyproj._datadir'" after I made .py to .exe with pyinstaller

my java code gets compilation error.how to fix it?

How can I fix this cross-compilation linking error

How do I fix this libgcrypt cross-compilation error?

How can I fix sfml c++ code compilation error?

How to fix compilation error for ESP32 in Arduino IDE?

How to fix the "WARNING: Hidden import" error pygame._view "not found!" after I turned my .py program into .exe?

Pygame not loading png after making .exe with Pyinstaller

Working code crashing after made into an EXE by pyinstaller

Cannot open .exe after pyinstaller convert

How to coding to fix Fatal error detected : Failed to execute script BoxDetection after use auto-py-to-exe compile python code to exe file?

Pyinstaller with pandas and numpy, exe throws error at runtime

PyInstaller exe returning error on a Tkinter script

Chromedriver Path Error when converting to .exe Pyinstaller

Error creating .exe (pyinstaller) with cloudscraper module [Python]

Python pyinstaller error when converting py to exe

Pyinstaller Error when running the exe file

How can I fix .exe stopped working error?

How to fix "ImportError: unable to find Qt5Core.dll on PATH" after pyinstaller bundled the python application

How to fix &quot;WARNING: Hidden import &quot;pygame._view&quot; not found!&quot; when converting .py to .exe using PyInstaller?

How to fix a pyinstaller 'no module named...' error when my script imports the modules pikepdf and pdfminer3?

How to update exe details generated by PyInstaller?

Pyinstaller and --onefile: How to include an image in the exe file