My code works well when it's .py but when I make .exe file with pyinstaller, it shows ModuleNotFoundError.
I write this when I made .exe
pyinstaller -F MyCode.py
How can I solve this problem?
I've read
Issues with pyinstaller and pyproj
and I was going to try to make and located hook-pyproj.py at "hooks" folder in Pyinstaller. but hook-pyproj.py was already there with the same code.
After that, I installed "basemap" and tried to use pyproj from it. However it shows me the same error.
This is the error it showed me when I execute the .exe file. (I covered some information with *****)
Traceback (most recent call last):
File "collect\MyCode.py", line 8, in <module>
File "c:\users\*****\appdata\local\programs\python\python36-32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\mpl_toolkits\basemap\__init__.py", line 41, in <module>
File "c:\users\*****\appdata\local\programs\python\python36-32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\pyproj\__init__.py", line 62, in <module>
File "c:\users\*****\appdata\local\programs\python\python36-32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\pyproj\crs.py", line 26, in <module>
File "pyproj\_crs.pyx", line 1, in init pyproj._crs
ModuleNotFoundError: No module named 'pyproj._datadir'
[25936] Failed to execute script MyCode
This is my code.
from mpl_toolkits.basemap import pyproj as pyproj
I tried this at first.
import pyproj
but I get same " ModuleNotFoundError: No module named 'pyproj._datadir' " error.
It's a bit odd and I don't exactly understand why but I found a quick dirty fix. You can add this import
from pyproj import _datadir, datadir
to your existing one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With