I use Python 3.11.5 and Miniconda. I would like to create a Windows exe. The executable should display the content of the file on the console.
After creating and running the resulting executable, I get the error "Cannot find the ecCodes library". How can I add the ecCodes library?
I have installed eccodes with Conda:
conda install -c conda-forge eccodes
conda install -c conda-forge python-eccodes
As described here: How to install ecCodes with Python Binding in Conda
import xarray as xr
def load_grib2_as_xarray(file_path):
try:
dataset = xr.open_dataset(file_path)
return dataset
except Exception as e:
print(f"Error loading the file: {e}")
return None
data = load_grib2_as_xarray("E:\\Coding_Projects\\PyCharm_Workspace\\pythonProject\\Grib2_data.grib2")
print(data)
- main.spec for pyIntsaller:
a = Analysis(
['main.py'],
pathex=[],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
noarchive=False,
)
pyz = PYZ(a.pure)
exe = EXE(
pyz,
a.scripts,
[],
exclude_binaries=True,
name='main',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
coll = COLLECT(
exe,
a.binaries,
a.datas,
strip=False,
upx=True,
upx_exclude=[],
name='main',
)
Result: error "Cannot find the ecCodes library"
- setup.py for py2exe:
from distutils.core import setup
import py2exe
setup(console=['main.py'])
Result: error "Cannot find the ecCodes library"