0

I have the following two lines of code which I’m trying to turn into an executable using pyinstaller.

import pandas as pd 
print('hello')

I’m using the command pyinstaller --onefile hello.py and the executable is created without exception. However, when I try to run the exe file, I receive the following error: "DLL load fail when importing _bz2"

The exact error looks like:

File "Hello.py", line 1, in <module>
  File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
  File "pandas\__init__.py", line 22, in <module>
  File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
  File "pandas\compat\__init__.py", line 24, in <module>
  File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
  File "pandas\compat\compressors.py", line 7, in <module>
  File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
  File "bz2.py", line 17, in <module>

ImportError: DLL load failed while importing _bz2: The specified module could not be found.

I've tried uninstalling and re installing pandas and pyinstaller. I've found a a few online solutions, but I'm wondering if the could be simpler.

I have pandas 2.0.5 installed.

Missing BZ2 module in python

https://www.pythonpool.com/fixed-modulenotfounderror-no-module-named-_bz2/

Oscar Schafer
  • 1,215
  • 1
  • 12
  • 25

0 Answers0