I am trying to write my first “helloworld” program to post on Twitter.
The program works fine with print("helloworld")
.
It also works with import tweepy.
But as soon as I try to assign my IDs, I get errors that it doesn’t recognize the API calls. (see attached screenshot)
Maybe its obvious, but I am a beginner Python programmer, and I’m basically copying what I saw in a YouTube video.
Question posted in Twitter API
The official Twitter API documentation can be found here.
The official Twitter API documentation can be found here.
2
Answers
I accidentally typed “python helloworld.py” instead of “python3”and it magically worked! So now I just run it that way.
You should be able to fix this issue by replacing the import with
and then replace your
auth=
line withNow as to why this is occuring – it could be dependant on what’s being imported. If you have another tweepy.py file for example, it could be getting picked up as the file to import from, which of course, is likely wrong. Using the from import resolves this. You can find out which file was being used by adding (still using the code from the version in the image you posted)
This’ll give you an idea whether the correct file was being imported or not.
Hope that helps.