tags:

views:

108

answers:

2

I am attempting to use the tweepy api to make a twitter function and I have two issues. I have little experience with the terminal and Python in general.

1) It installed properly with Python 2.6, however I can't use it or install it with Python 3.1. When I attempt to install the module in 3.1 it gives me an error that there is no module setuptools. Originally I thought that perhaps I was unable to use tweepy module with 3.1, however in the readme it says "Python 3 branch (3.1)", which I assume means it is compatible. When I searched for the setuptools module, which I figured I could load into the new version, there was only modules for up to Python 2.7. How would I install the Tweepy api properly on Python 3.1?

2) My default Python when run from terminal is 2.6.1 and I would like to make it 3.1 so I don't have to type python3.1.

+1  A: 

Install Distribute which is a compatible fork of setuptools that does support Python 3. When doing so, make sure you are using Python 3 instead of Python 2. Most Python 3 installations provide a symlimk or command named python3, whereas python refers to a Python 2 installation. Because of the incompatible differences between Python 2 and Python 3, it is recommended that you don't try to override this and have python refer to python3.

Ned Deily
After installation of Distribute, which had a few strange syntax errors, I checked info on the Tweepy module using help() and returned this:help> tweepyproblem in /Library/Frameworks/Python.framework/Versions/3.1/lib/python3.1/site-packages/tweepy-1.2-py3.1.egg/tweepy/api.py - SyntaxError: invalid syntax (api.py, line 302)
MBguitarburst
I see where it mentions Python 3 but looking at the code it doesn't appear as if it were tested with Python 3; like with the errors you see. You might want to open another issue at the project. In the meantime, you might want to stick to using Python 2 for it.
Ned Deily
Thanks, I appreciate the help.
MBguitarburst
You're welcome. BTW, if you ask a question on StackOverflow, it's expected that you'll either mark an answer as accepted (so that the answerer receives points) or edit and refine the question until you do get an acceptable answer.
Ned Deily
While I did not solve my problem I appreciate the effort and you have given me insight and knowledge.
MBguitarburst
Keep in mind that, relatively speaking, Python 3 is still very new and most 3rd-party modules have not yet been ported from Python 2. It will take some years before Python 3 overtakes Python 2. In the meantime, Python 2 will still be supported (Python 2.7 was just recently released). So if the choice of Python versions is not critical to your project, Python 2 might be a better choice at the moment. Another approach is to try to use the Python 2 to 3 converter, `2to3`, on Tweety and see what happens: http://docs.python.org/py3k/library/2to3.html
Ned Deily
A: 

Update: The comments below have some solid points against this technique.

2) What OS are you running? Generally, there is a symlink somewhere in your system, which points from 'python' to 'pythonx.x', where x.x is the version number preferred by your operating system. On Linux, there is a symlink /usr/bin/python, which points to (on Ubuntu 10.04) /usr/bin/python2.6 on a standard installation.

Just manually change the current link to point to the python3.1 binary, and you are fine.

dermatthias
I am using a Mac OS 10.6.4, and which python returns /usr/bin/python which I'm not exactly sure how to change. Also, $PATH results in /Library/Frameworks/Python.framework/Versions/3.1/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin: No such file or directory
MBguitarburst
Ugh! Do *not* change `/usr/bin/python` on OS X. It is not a symlink. It is part of OS X and managed by Apple. Changing your `PATH` is preferred. And on any system it would be a bad idea to change `/usr/bin/python` to point at a Python 3 installation: too many things will break.
Ned Deily
Right, good points against using this technique. It worked for me (on Linux, never tried it on OS X) in some cases. I thought changing a symlink (which is easy to revert) is at least worth a try.
dermatthias