Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'module' object has no attribute 'Channel' #20

Open
desxblax96 opened this issue Jul 21, 2021 · 1 comment
Open

AttributeError: 'module' object has no attribute 'Channel' #20

desxblax96 opened this issue Jul 21, 2021 · 1 comment

Comments

@desxblax96
Copy link

desxblax96 commented Jul 21, 2021

I am executing the code on my raspberry pi and i am getting this error
AttributeError: 'module' object has no attribute 'Channel'

CODE:

import thingspeak
import time
import json
channel_id = 0# PUT CHANNEL ID HERE
write_key = 'gjgjgj' # PUT YOUR WRITE KEY HERE
read_key = 'vhjjvhj' # PUT YOUR API KEY HERE, (read access only)

channel = thingspeak.Channel(id=channel_id, api_key=read_key)

while True:
try:
# Get the last 2 results from field 1 of your channel
data = json.loads(channel.get_field(field=1, options={"results": 2}))
print(data['feeds'])
except:
raise
print("connection failed")
time.sleep(10)

@ichesworth
Copy link

For anyone trying to troubleshoot this issue, I had the same problem. For me I had stupidly called my program thingspeak.py so the import wasn't pulling in the library at all but my program again! I renamed the program to ts.py and it worked fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants