lukaskubis / darkskylib

Python wrapper for the Dark Sky API
https://pypi.org/project/darkskylib/
MIT License
113 stars 23 forks source link

ImportError: cannot import name forecast #21

Open ParityError opened 4 years ago

ParityError commented 4 years ago

I installed via:

$ sudo pip uninstall darksky && pip install darkskylib --upgrade --no-cache- --force-reinstall

and get the following error:

$ python darksky_example.py 
Traceback (most recent call last):
  File "darksky_example.py", line 1, in <module>
    from darksky import forecast
  File "darksky_example.py", line 4, in <module>
    from darksky import forecast
ImportError: cannot import name 'forecast'

Using this exact code:

from darksky import forecast
from datetime import date, timedelta

BOSTON = 42.3601, 71.0589

weekday = date.today()
with forecast('API_KEY', *BOSTON) as boston:
    print(boston.daily.summary)
    for day in boston.daily:
        day = dict(day = date.strftime(weekday, '%a'),
                   sum = day.summary,
                   tempMin = day.temperatureMin,
                   tempMax = day.temperatureMax
                   )
        print('{day}: {sum} Temp range: {tempMin} - {tempMax}'.format(**day))
        weekday += timedelta(days=1)

Info: Python 3.6.9

lukaskubis commented 4 years ago

I'd recommend to try this in a clean docker container like so:

docker run -it python:3.7-slim sh

once inside, try to replicate, if that won't help, we indeed have a problem here.