0

I am new to both python and Aptana.

I am trying to use the tweepy package in python. I have the following code (from python's site):

import tweepy

user = tweepy.api.get_user('twitter') # "undefined variable" error occurs on this line
print user.screen_name
print user.followers_count
for friend in user.friends():
    print friend.screen_name

I get an "Undefined variable from import: get_user". The code actually runs fine with no errors and produces the expected results. I googled and found how to resolve the undefined variable error, but it seems like a hack-a-round. In sum, that link says to add "get_user" to globals in the preferences.

Being new to both Python and Aptana, I just wanted to check to see if that is the best way to resolve it....it just seems like a hack. When I change "tweepy.api.get_user" to "tweepy.api.public_timeline" I get the same error and thus will have to manually add "public_timeline" to the globals....It doesn't seem like the correct way when you have to manually configure each variable.

thanks!

user_78361084
  • 3,538
  • 22
  • 85
  • 147
  • @DSM Reading between the lines a little, I think it's a bug in Aptana Studio, not Tweepy (Aptana reports an error and highlights `get_user` in red, even though there is nothing actually wrong with the code). – Jason Orendorff Aug 10 '12 at 19:08
  • @DSM...that's kind of what I think but being a newb wanted to check. Why doesn't Aptana do the same thing w/ other packages? btw, I am using tweepy version 1.1 – user_78361084 Aug 10 '12 at 19:11

2 Answers2

1

If you would like to not be warned about this you may exclude the warning:

goto Window -> Preferences -> PyDev -> Editor -> Code Analysis

Click on the Undefined tab and add get_user to the textbox. That will clear up your warning.

Andrew

Andrew Kloos
  • 4,189
  • 4
  • 28
  • 36
  • Does your app throw an error when you try to run it? I agree with Jason that with the information you've given us Aptana is incorrectly labeling get_user as undefined. If that's not the case give us more info. – Andrew Kloos Aug 10 '12 at 19:53
  • "The code actually runs fine with no errors and produces the expected results. " – user_78361084 Aug 10 '12 at 20:01
  • Here's a link that may help you. http://stackoverflow.com/questions/7281955/pydev-say-unresolved-import-error – Andrew Kloos Aug 10 '12 at 20:14
0

I had a Problem similar to your case (also using PyDev with Aptana).

I upgraded Aptana and PyDev with the following instructions:

Update PyDev on Aptana

after the upgrade PyDev worked just fine for me :)

Community
  • 1
  • 1
  • Whilst this may theoretically answer the question, [it would be preferable](http://meta.stackoverflow.com/q/8259) to include the essential parts of the answer here, and provide the link for reference. – Yurii Mar 30 '15 at 13:18