Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using auto-py-to-exe does not work with wetterdienst #843

Open
Philly-V opened this issue Jan 9, 2023 · 2 comments
Open

Using auto-py-to-exe does not work with wetterdienst #843

Philly-V opened this issue Jan 9, 2023 · 2 comments

Comments

@Philly-V
Copy link

Philly-V commented Jan 9, 2023

Hello,

I am trying to create an .exe with auto-py-to-exe out of my Python script which uses wetterdienst to access wind and air pressure data from DWD stations around germany. To make it portable without using a virtual environment I tried to convert the script to an .exe. Executing the .exe throws the following error:

  File "main.py", line 10, in <module>
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module
  File "wetterdienst\__init__.py", line 18, in <module>
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module
  File "wetterdienst\api.py", line 8, in <module>
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module
  File "wetterdienst\provider\dwd\mosmix\__init__.py", line 4, in <module>
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module
  File "wetterdienst\provider\dwd\mosmix\api.py", line 15, in <module>
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module
  File "wetterdienst\core\scalar\request.py", line 38, in <module>
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module
  File "wetterdienst\settings.py", line 14, in <module>
  File "wetterdienst\settings.py", line 18, in Settings
  File "environs\__init__.py", line 415, in read_env
  File "dotenv\main.py", line 253, in _walk_to_root
OSError: Starting path not found

Note that line 10 in main.py is:

from wetterdienst.provider.dwd.observation import DwdObservationRequest, DwdObservationDataset, DwdObservationPeriod, \
    DwdObservationResolution, DwdObservationParameter

It seems the error comes from wetterdienst using dotenv to access a path which is nonexistent (probably because the script was converted to an executable). Since I don't have much knowledge about the how dotenv works and ran most of my Python scripts inside the IDE I work with I am not sure if this is a wetterdienst-related problem, or rather a problem with auto-py-to exe or my limited knowledge about it, but maybe you can tell me if it is possible to convert the script to an .exe or if I rather should use a virtual environment to make it portable.

The script is working when executed inside an IDE and on another computer when all required packages are installed with pip (which is what I try to avoid).

**Desktop

  • OS: Windows 10
  • Python-Version 3.10
  • IDE: PyCharm Pro / Community Edition

Thanks in advance
Phillip

@meteoDaniel
Copy link
Contributor

Dear @Philly-V, it seems that this i neither a problem with wetterdienst nor with dotenv.

The error occurs in _walk_to_root which is typically for missing environment files. You have to take care of total paths.
Do you mount the env into the exe?

Please check this out and let us know if it works or not.

Best regards

@amotl
Copy link
Member

amotl commented Jan 18, 2023

Dear @Philly-V,

on your endeavor, you might be successful using PyInstaller 1, see also GH-823.

With kind regards,
Andreas.

Footnotes

  1. https://github.com/pyinstaller/pyinstaller

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants