Error posting to Twitter with new API - module object has no attribute Api

570 views
Skip to first unread message

Ross McDonald

unread,
Jun 25, 2013, 10:04:34 AM6/25/13
to py...@googlegroups.com
Hello list

I have recently upgraded pywws to the latest 13 06 release using the github repo. I upgraded tweepy using the github repo and removed the older python-tweepy I had installed from the ubuntu 12.04 repos.

Hourly works perfectly if my weather.ini file has nothing in the [twitter] fields and all graphs and templates are processed and uploaded to my website.  If I add 'tweet.txt' to hourly and 'forecast_tweet.txt' in the 12 hourly section I get the following error.

21:00:56:pywws.LogData:Fetching data
21:00:57:pywws.LogData:4 catchup records
21:00:57:pywws.Process:Generating summary data
21:00:57:pywws.Calib:Using default calibration
Traceback (most recent call last):
  File "/usr/share/weather/pywws/pywws/Hourly.py", line 109, in <module>
    sys.exit(main())
  File "/usr/share/weather/pywws/pywws/Hourly.py", line 106, in main
    return Hourly(args[0])
  File "/usr/share/weather/pywws/pywws/Hourly.py", line 78, in Hourly
    params, status, calib_data, hourly_data, daily_data, monthly_data
  File "/usr/local/lib/python2.7/dist-packages/pywws/Tasks.py", line 200, in do_tasks
    OK = self._do_common(sections)
  File "/usr/local/lib/python2.7/dist-packages/pywws/Tasks.py", line 118, in _do_common
    if not self.do_twitter(template):
  File "/usr/local/lib/python2.7/dist-packages/pywws/Tasks.py", line 216, in do_twitter
    twitter = ToTwitter.ToTwitter(self.params)
  File "/usr/local/lib/python2.7/dist-packages/pywws/ToTwitter.py", line 72, in
__init__
    self.api = twitter.Api(
AttributeError: 'module' object has no attribute 'Api'

The documentation seems to show two different methods of including tweets (http://jim-easterbrook.github.io/pywws/doc/en/html/guides/hourlylogging.html) where tweet templates are included in the [twitter] section and on (http://jim-easterbrook.github.io/pywws/doc/en/html/guides/twitter.html#add-twitter-updates-to-your-hourly-tasks) the tweet template is added to the [text] section with a T flag.

Have I got conflicting packages installed?

Thanks

Ross

Nick McGill

unread,
Jun 25, 2013, 10:47:34 AM6/25/13
to py...@googlegroups.com
The most recent version on git no longer uses tweepy, but has moved on to python-twitter - you'll need to build the documentation locally to get the latest requirements.

Cheers

Nick
--
You received this message because you are subscribed to the Google Groups "pywws" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pywws+un...@googlegroups.com.
To post to this group, send an email to py...@googlegroups.com.
Visit this group at http://groups.google.com/group/pywws.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Jim Easterbrook

unread,
Jun 25, 2013, 12:35:18 PM6/25/13
to py...@googlegroups.com
On 25/06/13 15:04, Ross McDonald wrote:
>
> I have recently upgraded pywws to the latest 13 06 release using the
> github repo.

That's confusing. "release" is the word I use for one of the snapshots I
upload to PyPI every two or three months. If you've cloned the GitHub
repo then you have the development version.

As Nick has pointed out, since the last release the development version
has dropped tweepy in favour of python-twitter, because the tweepy
developer has announced its retirement.

In retrospect I probably should have made it use whichever library you
have installed, at least for a transitional period.

> The documentation seems to show two different methods of including
> tweets
> (http://jim-easterbrook.github.io/pywws/doc/en/html/guides/hourlylogging.html)
> where tweet templates are included in the [twitter] section and on
> (http://jim-easterbrook.github.io/pywws/doc/en/html/guides/twitter.html#add-twitter-updates-to-your-hourly-tasks)
> the tweet template is added to the [text] section with a T flag.

You (currently) have a choice. The 'T' flag syntax is new and is
intended to replace the 'twitter' item in the '[hourly]' section. Note
that the '[twitter]' section is used to store your authorisation
credentials, it does not include a list of templates.
--
Jim Easterbrook <http://www.jim-easterbrook.me.uk/>

Ross McDonald

unread,
Jun 25, 2013, 3:11:27 PM6/25/13
to py...@googlegroups.com
You're right - I have the development version installed.  I also had Ubuntu's version of python-twitter installed as well as tweepy.  Ubuntu version of python-twitter is purged, tweepy removed and python-twitter 1.0 installed using:

pip install python-twitter

I currently use 'tweet.txt' in the twitter item in [hourly] but will try the new format in the text item.

Tweets are now working again.  Thank you both for the helpful pointers.

Jim Easterbrook

unread,
Jun 25, 2013, 3:17:33 PM6/25/13
to py...@googlegroups.com
On 25/06/13 20:11, Ross McDonald wrote:
> You're right - I have the development version installed. I also had
> Ubuntu's version of python-twitter installed as well as tweepy. Ubuntu
> version of python-twitter is purged, tweepy removed and python-twitter
> 1.0 installed using:
>
> pip install python-twitter

No need to purge tweepy, but no harm in doing so.

Can you find out what version of python-twitter Ubuntu was installing?
(I don't know how easy Ubuntu's package manager makes it to answer such
questions.) Version 0.8.6 (from OpenSUSE Python build service) works, so
I guess it's older than that.

Ross McDonald

unread,
Jun 25, 2013, 3:23:15 PM6/25/13
to py...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages