1

I am using the following code with Python 3.3 modules (installed using Pip3.3):

import simplejson
import httplib2
import twitter

api = twitter.Api(consumer_key='',
                      consumer_secret='',
                      access_token_key='',
                      access_token_secret='')

The specific modules installed are 'python-twitter 1.3.1' and it's dependencies 'httplib2 0.8', 'python-oauth2 0.6.0' and 'simplejson 3.3.3' which are all the most up to date versions on the PYPI directory.

I am receiving an error message pointing to line 56 of the twitter library though:

Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    import twitter
  File "C:\Python33\lib\site-packages\twitter.py", line 56
    raise ImportError, "Unable to load a json library"
                     ^
SyntaxError: invalid syntax

Above that module in the code is the following statements:

try:
  # Python >= 2.6
  import json as simplejson
except ImportError:
  try:
    # Python < 2.6
    import simplejson
  except ImportError:
    try:
      # Google App Engine
      from django.utils import simplejson
    except ImportError:
      raise ImportError, "Unable to load a json library"

Does this mean that as I am Python version 3.3 that I also have to have a json library installed to make this code work? I haven't tried installing this yet as I don't want to confuse the issue further before asking for help.

Any ideas?

Thanks

gdogg371
  • 3,879
  • 14
  • 63
  • 107
  • ive tried playing around with the code in the twitter module and it keeps seeming through up errors around commas. any idea why this might be? – gdogg371 Apr 03 '14 at 18:27
  • 1
    The python-twitter module can not be used on Python 3. The syntax of `except` changed. Use python 2.7 if you need this module. (You could also try porting the module to Python 3, but that's obviously above your current skill level...) – Wooble Apr 03 '14 at 18:31

1 Answers1

0

The correct answer is in the comments section above. The Python-Twitter module will not work with any versions of Python after 2.7.

gdogg371
  • 3,879
  • 14
  • 63
  • 107