3

I am beginning to work with PyInstaller to create exe file from my Python scripts, but i have problem with netCDF4 module. I am working on windows 7. The code is really simple:

from netCDF4 import Dataset
out = Dataset("file.nc", "w")
out.GA = "ok"
out.close()
print("ok")

I started creating a virtual environment using

python -m venv v_env_x1

and activate it with

Scripts\Activate

then I install on v_env directory the netCDF4 and PyInstaller modules

pip install netCDF4
pip install PyInstaller

finally I created the exe file with

PyInstaller script.py --onefile

The command generates the exe file, but when I try to run it this error appears:

ModuleNotFoundError: No module named 'cftime'

If I use pip list command however the cftime module is present in the virtual environment! Moreover if I use the command

python script.py

the code runs normally. Someone can help me? Below there is the result of pip list command

Package                   Version
------------------------- ---------
altgraph                  0.17
cftime                    1.2.1
future                    0.18.2
netCDF4                   1.5.4
numpy                     1.19.1
pefile                    2019.4.18
pip                       20.2.2
pyinstaller               4.0
pyinstaller-hooks-contrib 2020.7
pywin32-ctypes            0.2.0
setuptools                39.0.1

Thank you

Ezecamele
  • 31
  • 4

0 Answers0