csparpa / pyowm

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

Attribute Error OWM #218

Closed PhilippTh closed 6 years ago

PhilippTh commented 6 years ago

I always get AttributeError: module 'pyowm' has no attribute 'OWM' even when using the example code in the docs.

csparpa commented 6 years ago

Hi @PhilippTh I need you to provide more detail in order to be able to help you

Can you please paste here the exact code that is not working? Or at least a reference to the part of the docs you are referring to

Thanks

PhilippTh commented 6 years ago

Hi, thank you @csparpa for the quick response! The code I'm using is from your example code in the docs folder.

from pyowm import OWM API_key = 'I use my own API' owm = OWM(API_key) w = owm.daily_forecast(location) print (w)

Thanks for the help!

edit: I use the latest python version (3.6.3) on windows 10 edit2: I just tried it on ubuntu but that made no difference

csparpa commented 6 years ago

So... You said you have an installation on Ubuntu. Can you please launch the command

pip show pyowm

and paste here the full output of it? Thanks man

csparpa commented 6 years ago

Also @PhilippTh please paste the output of

pip3 show pyowm

My doubt is that you are using Python3 but installed PyOWM using pip for Python 2 !

PhilippTh commented 6 years ago

The outcome to both commands is:

C:\Users\Philipp>pip3 show pyowm
Name: pyowm
Version: 2.7.1
Summary: A Python wrapper around the OpenWeatherMap web API
Home-page: http://github.com/csparpa/pyowm
Author: Claudio Sparpaglione (@csparpa)
Author-email: csparpa@gmail.com
License: MIT
Location: c:\users\philipp\appdata\local\programs\python\python36\lib\site-packages
Requires:
csparpa commented 6 years ago

What interpreter did you use to run the code that fails?

Can you also pls enter that interpreter and paste here the output of:

import sys
print(sys.path)

Thanks

PhilippTh commented 6 years ago

I used the python interpreter

the command outputs ['', 'C:\\Users\\Philipp\\AppData\\Local\\Programs\\Python\\Python36\\python36.zip', 'C:\\Users\\Philipp\\AppData\\Local\\Programs\\Python\\Python36\\DLLs', 'C:\\Users\\Philipp\\AppData\\Local\\Programs\\Python\\Python36\\lib', 'C:\\Users\\Philipp\\AppData\\Local\\Programs\\Python\\Python36', 'C:\\Users\\Philipp\\AppData\\Local\\Programs\\Python\\Python36\\lib\\site-packages']

csparpa commented 6 years ago

@PhilippTh I've just tried to run your code on Linux+Python3.6.3 setup, it works like a charm...

Please bear with me and do this test for me please:

  1. use your Ubuntu setup, not Windows - what Ubuntu version is it?
  2. create a file with this code
import traceback
try:
    raise ValueError()
except:
    traceback.print_exc()

and then run the file with the same interpreter that gave you the errors before.

Eventually, please paste here the stack trace. Thanks a lot

PhilippTh commented 6 years ago

I´d like to thank you for your patience with me and all the quick responses.

1.I´m using a raspberry pi with the latest distribution of raspbian jessie 2.I tried this, and the output was:

Traceback (most recent call last):
  File "test.py", line 3, in <module>
    raise ValueError()
ValueError

edit: I flashed my sim card and setup everything again and the error seems to not occure anymore. When you said the code I provided would work like a charm, what exactly do you mean by that? What output did you get? Mine now is <pyowm.webapi25.forecaster.Forecaster>

csparpa commented 6 years ago

My output was exactly as yours - you get the object printed out!

So you made it! Congrats!

Nobody will ever guess what the issue was, but that's OK as far as the library works ;)