no attribute 'OWM'
See original GitHub issueWhat’s wrong? At start of the code the error jumps out. I am writing using Thonny. I work on raspberry pi 3 b +. thonny error:
Traceback (most recent call last): File "/home/pi/pyowm.py", line 1, in <module> import pyowm File "/usr/lib/python3/dist-packages/thonny/backend.py", line 305, in _custom_import module = self._original_import(*args, **kw) File "/home/pi/pyowm.py", line 3, in <module> owm = pyowm.OWM('194277e0479d5a36ebb28e1a81c18006') AttributeError: module 'pyowm' has no attribute 'OWM'
terminal error:
Traceback (most recent call last): File "pyowm.py", line 1, in <module> import pyowm File "/home/pi/pyowm.py", line 3, in <module> owm = pyowm.OWM('194277e0479d5a36ebb28e1a81c18006') AttributeError: 'module' object has no attribute 'OWM'
code:
`import pyowm
owm = pyowm.OWM(‘194277e0479d5a36ebb28e1a81c18006’)
observation = owm.weather_at_place(‘London,GB’) w = observation.get_weather() print(w)`
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
@romaKadeta In the error msg you’ve posted, I can read:
ImportError: cannot import name 'OWM' from 'pyowm' (/home/pi/pyowm.py)
It looks like you’re running a script named
pyowm.py
of your own, which attempts to import the installed PyOWM library. So, the name of the script and of the library clash.Try to rename your script to any other thing different than “pyowm.py” and check if it works fine… Let me know!
I had similar issue. I am not sure what was causing the problem, but I’ve tried:
and then I’ve uninstalled packages via:
and then installed back again for Python3
sudo pip3 install pyowm
After that the same script works fine for me without error message.