im trying to work with the twitter api with python3.3 in windows
while I try to install using
python setup.py install
I get this error:
raise ImportError, "Unable to load a json library"
to solve this i install the simple json module manually
the error comes back again
Traceback (most recent call last):
File "C:\Users\schatterjee\workspace\test\test.py", line 1, in <module>
import twitter
File "C:\Python33\lib\site-packages\twitter.py", line 50
raise ImportError, "Unable to load a json library"
^
SyntaxError: invalid syntax
why is this persisting?
Okay, the traceback did help a lot. The problem is not, as originally assumed, that there is no JSON library. Instead you get a syntax error on the line that would throw an error (it doesn’t throw it though!).
The reason you get the syntax error is because the displayed syntax is Python 2 syntax:
raise ExceptionType, "message"
This syntax is no longer a valid syntax in Python 3 but must be written as
raise ExceptionType(message)
The error supports my assumption that the Twitter library you picked is not compatible with Python 3. There are in fact multiple things within the library that would throw further syntax errors. I’m surprised that they didn’t add a check to the setup.py to inform you about this though.
So, unfortunately, you will not be able to use this library with Python 3, but need to use Python 2. You can install both Python 2 and Python 3 in parallel on your computer, if you want to.
You could however also look for a different library. Here are two that are compatible with Python 3; I haven’t tried either of them though:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With