csparpa / pyowm

A Python wrapper around the OpenWeatherMap web API
https://pyowm.readthedocs.io
MIT License
789 stars 171 forks source link

AttributeError: 'OWM25' object has no attribute 'weather_manager' #328

Closed Saurav-Navdhare closed 4 years ago

Saurav-Navdhare commented 4 years ago

This is my error: Traceback (most recent call last): File "project.py", line 6, in <module> mgr = owm.weather_manager() AttributeError: 'OWM25' object has no attribute 'weather_manager'

My code:

from pyowm import OWM
API_KEY='xxxxxxxxxxxxxxxxxxxxxxxxxxxxx

owm = OWM(API_KEY)
mgr = owm.weather_manager()
obs = mgr.weather_at_place('Sydney, AU')
weather = obs.weather
temperature = weather.temperature(unit='celsius')['temp']
print(f'The temperature is {temperature} degrees Celsius.')

I was reading the example from next.tech and the same code works there.

csparpa commented 4 years ago

Hi, what is your pyowm version?

Saurav-Navdhare commented 4 years ago

Hi, what is your pyowm version?

I have 2.10.0

I tried to update it but it is showing the following error;

"ERROR: Could not find a version that satisfies the requirement pyowm>=3 (from -r requirements.txt (line 1)) (from versions: 0.2.0, 0.4.0, 0.4.1, 1.0.0 , 1.2.0, 2.0.0, 2.2.0, 2.2.1, 2.3.0, 2.3.1, 2.3.2, 2.4.0, 2.5.0, 2.6.0, 2.6.1, 2.7.1, 2.8.0, 2.9.0, 2.10.0) ERROR: No matching distribution found for pyowm>=3 (from -r requirements.txt (line 1))"

csparpa commented 4 years ago

Ok so: the documentation you've read refers to PyOWM version 3.

PyOWM v2 is old stuff and you should not use it anymore.

So you need to update:

pip3 install --upgrade pyowm

As stated in the project docs, this might BREAK YOUR EXISTING CODE : please refer to the migration guide in the docs!

Saurav-Navdhare commented 4 years ago

pip3 install --upgrade pyowm This shows up when running upgrade with pip, pip3, python -m pip

WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
Defaulting to user installation because normal site-packages is not writeable
Requirement already up-to-date: pyowm in c:\users\admin\appdata\roaming\python\python36\site-packages (2.10.0)
Requirement already satisfied, skipping upgrade: geojson<3,>=2.3.0 in c:\users\admin\appdata\roaming\python\python36\site-packages (from pyowm) (2.5.0
)
Requirement already satisfied, skipping upgrade: requests<3,>=2.20.0 in c:\users\admin\appdata\roaming\python\python36\site-packages (from pyowm) (2.2
3.0)
Requirement already satisfied, skipping upgrade: certifi>=2017.4.17 in c:\users\admin\appdata\roaming\python\python36\site-packages (from requests<3,>
=2.20.0->pyowm) (2020.4.5.1)
Requirement already satisfied, skipping upgrade: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in c:\users\admin\appdata\roaming\python\python36\site-packag
es (from requests<3,>=2.20.0->pyowm) (1.25.9)
Requirement already satisfied, skipping upgrade: chardet<4,>=3.0.2 in c:\users\admin\appdata\roaming\python\python36\site-packages (from requests<3,>=
2.20.0->pyowm) (3.0.4)
Requirement already satisfied, skipping upgrade: idna<3,>=2.5 in c:\users\admin\appdata\roaming\python\python36\site-packages (from requests<3,>=2.20.
0->pyowm) (2.9)
csparpa commented 4 years ago

I would suggest you completely wipe out PyOWM (eg. with pip3 uninstall pyowm) and then reinstall the proper v3 version with:

pip3 install pyowm==3.0.0
Saurav-Navdhare commented 4 years ago

I would suggest you completely wipe out PyOWM (eg. with pip3 uninstall pyowm) and then reinstall the proper v3 version with:

Man, I wiped out pyowm, and even python. pip still installs 2.10.x while, the exact same command works on termux perfectly.

csparpa commented 4 years ago

I think it's because you have a Python 2 environment, therefore the pip coming with that environment can only install PyOWM up to 2.10 because that is the latest release supporting Python 2.

So make sure you use Python 3 instead!