earthobservations / wetterdienst

Open weather data for humans.
https://wetterdienst.readthedocs.io/
MIT License
360 stars 55 forks source link

Problems installing wetterdienst #530

Closed jeiglsperger closed 2 years ago

jeiglsperger commented 3 years ago

After installing wetterdienst via pip3 install wetterdienst and start running my algo, I received this error:

ModuleNotFoundError: No module named 'wetterdienst.provider'

By installing wetterdienst via pip install wetterdienst I received the error:

Could not find a version that satisfies the requirement wetterdienst (from versions: ) No matching distribution found for wetterdienst`

So my question would be which version of pip should be used for installing the library or if somebody knows another way of solving this issue?

gutzbenj commented 3 years ago

Dear @Zepp3 ,

I'm not really sure what this bug is related to but you should always be using the newest pip as pip itself is advertising when running an out-of-date version of pip.

Furthermore could you provide is with the exact code block that leverages the wetterdienst package?

jeiglsperger commented 3 years ago

Hi @gutzbenj,

thanks for your answer.

I updated pip to pip-20.3.4. The problem still occurs.

The code block that leverages wetterdienst is:

import pandas as pd
from datetime import datetime
from geopy.location import Location
from wetterdienst.provider.dwd.observation import DwdObservationRequest, DwdObservationPeriod, DwdObservationResolution, DwdObservationParameter, DwdObservationDataset
from dwdweather import DwdWeather

def calc_daily_mean_weather_values(location: Location) -> pd.Series:
    weather_df = pd.DataFrame()
    stations = DwdObservationRequest(DwdObservationDataset.TEMPERATURE_AIR, resolution=DwdObservationResolution.HOURLY, 
                                         period=DwdObservationPeriod.RECENT, start_date=datetime(2001, 1, 11), 
                                         end_date=datetime(2020, 10, 28), tidy=True, humanize=True, 
                                         si_units=True)
    print(stations.filter_by_distance(latitude=53.0, longitude=8.0, distance=100, unit="km"))

    return weather_df
gutzbenj commented 3 years ago

Do you have further information about your running system, python, etc as asked for in the template issue?

jeiglsperger commented 3 years ago

Oh sorry. Here you go:

OS: Ubuntu 18.04.4 LTS (GNU/Linux 4.15.0-111-generic x86_64) Python 3.6.9

amotl commented 3 years ago

Dear @Zepp3,

thanks for writing in. Without being able to bring anything sensible to the discussion yet, I can confirm Wetterdienst croaks like you described on the type of system you are using.

docker run --rm -it ubuntu:18.04 bash
apt-get update
apt-get install --yes python3 python3-pip nano
pip3 install wetterdienst geopy
root@220b568a874e:/# python3 test.py
Traceback (most recent call last):
  File "test.py", line 4, in <module>
    from wetterdienst.provider.dwd.observation import DwdObservationRequest, DwdObservationPeriod, DwdObservationResolution, DwdObservationParameter, DwdObservationDataset
ModuleNotFoundError: No module named 'wetterdienst.provider'

With kind regards, Andreas.

amotl commented 3 years ago

Indeed, this module seems to be missing from the installation.

$ python3
>>> import wetterdienst
>>> wetterdienst.__file__
'/usr/local/lib/python3.6/dist-packages/wetterdienst/__init__.py'
root@220b568a874e:/# ls -1 /usr/local/lib/python3.6/dist-packages/wetterdienst/
__init__.py
__pycache__
api.py
cli.py
core
dwd
exceptions.py
metadata
service.py
util
amotl commented 3 years ago

Root cause

Got it. Wetterdienst dropped support for Python 3.6 a while ago. So, when installing it on your system, you will get the most recent version available for Python 3.6, which happens to be 0.15.0.

root@220b568a874e:/# wetterdienst --version
wetterdienst 0.15.0

Evaluation

This is a perfect installation of Wetterdienst. However, you will not be able to use most recent code snippets as outlined in the documentation, matching version 0.21.0.

Solution 1

Keep your current environment and consult the documentation corresponding to version 0.15.0 [1]. We don't recommend this, because Wetterdienst received many valuable improvements in the meanwhile.

Solution 2

Use pyenv [2] for installing arbitrary versions of Python on your system without too much effort. This is what we usually do when being in similar situations.

[1] https://github.com/earthobservations/wetterdienst/tree/v0.15.0/docs [2] https://github.com/pyenv/pyenv

amotl commented 3 years ago

Solution 3

Apparently, Ubuntu 18.04 LTS already ships a minimal variant of Python 3.7. That is, the interpreter is there, but no package ecosystem.

Install prerequisites

# Install Python 3.7
apt-get install --yes python3.7 python3.7-dev wget

# Need to install some Python packages upfront. Don't know why.
python3.7 -m pip install numpy cython

wget https://files.pythonhosted.org/packages/33/ae/01f7faa8f58d7be568457deef657695877dfe02530923b6ee8f6c30e8b3b/rapidfuzz-1.4.1-cp37-cp37m-manylinux1_x86_64.whl
python3.7 -m pip install rapidfuzz-1.4.1-cp37-cp37m-manylinux1_x86_64.whl

wget https://files.pythonhosted.org/packages/e6/0a/90da8840e044c329a0271fb0244ff40a68a2615bc360c296a3dc5e326ab6/pandas-1.2.5-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
python3.7 -m pip install pandas-1.2.5-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl

Install packages

python3.7 -m pip install wetterdienst geopy

Outcome

I believe this output shows that the test program you shared at https://github.com/earthobservations/wetterdienst/issues/530#issuecomment-950571109 can run beyond where it previously croaked.

root@220b568a874e:/# python3.7 test.py
INFO: Wetterdienst cache directory is /root/.cache/wetterdienst
Traceback (most recent call last):
  File "test.py", line 5, in <module>
    from dwdweather import DwdWeather
ModuleNotFoundError: No module named 'dwdweather'

Caveat

Please note this is just a workaround for installation and has not been confirmed for validity or correctness in any way. Please let us know if this works for you and good luck!

gutzbenj commented 2 years ago

Dear @Zepp3 @amotl ,

I think we can close this at this moment . Do you agree?

amotl commented 2 years ago

Closing it. Please feel free to reopen if you see fit.

jeiglsperger commented 2 years ago

Hi @amotl and @gutzbenj,

thanks for your big help. Something went wrong with the notifications and therefore didn't receive your answers in this thread but I could resolve the problem with your suggestions.

Kind regards!