After the virtual environment was built, the Python file was made EXE with the pyinstaller Python filename --onefile --noconsole
.
After that, I tried to do it, but the following error (attached image) occurred.
Apparently, there is no module called cftime, so I was going to install it with pip, but when I was installing the package called netCDF4, it was installed together as follows:
(project_env)PST:\PROJECT_Automation>python-mpip install netCDF4
Collecting netCDF4
Using cached netCDF4-1.5.8-cp37-cp37m-win_amd64.whl (3.0 MB)
Requirement already satified: numpy>=1.9 int:\project_automation\project_env\lib\site-packages (from netCDF4) (1.21.6)
Collecting cftime
Using cached cftime-1.6.0-cp37-none-win_amd64.whl (154 kB)
Installing collected packages: cftime, netCDF4
Successfully installed cftime-1.6.0 netCDF4-1.5.8
In fact, when I checked with T:\PROJECT_Automation\project_env\Lib\site-packages, it was installed.
Why do I get an error saying I can't find the module?
I don't know how to solve it.
Thank you for your understanding.
This article seems to deal with the same problem.
It has not been answered, but it has been updated with comments, so it seems to have been resolved.
PyInstaller cftime module not found
add the flag -- hidden-imports cftime to your command.
Because you don't import the module directly, pyinstaller may not realize that's a needed dependency.
It works! Thank you very much!
However, you should add --hidden-imports cftime
, but you should actually have --hidden-import
at the end without s
and --hidden-imports cftime
.
Maybe it depends on the number of versions of PyInstaller.
The above article shows the source code and procedures for reproducing the problem, and we did so.
(I have updated the number of versions of pip and setuptools)
And as you can see in the comment (actually removing s
), the error disappeared and it now works.
The same is true of the question, so try it.
© 2024 OneMinuteCode. All rights reserved.