Posts

Showing posts with the label python

python 2.6 on debian lenny

Source:  http://mindref.blogspot.com/2010/04/python-26-on-debian.html Debian 5.0 comes with Python 2.5 since there is no newer version available in stable repository yet. So the question becomes how you can install a newer Python on your box. Usual way is to update from sid repository and install python version you need... but it doesn't work that way, unfortunately. You will see the following error: pycentral rtinstall: installed runtime python2.6 not found The only way to get rid of this error is by removing older version of python (please note that updating python 2.5 to latest version will not work). apt-get remove python2.5-minimal python2.5 rm -Rf /usr/bin/python /usr/bin/python2.5 /usr/lib/python2.4 /usr/lib/python2.5 /etc/python2.5 add sid repository, e.g.  deb http://ftp.us.debian.org/debian/ sid main , to /etc/apt/sources.list apt-get -y update apt-get -y install python python-setuptools python-virtualenv comment out sid repository in  /etc/apt/source...

Setting up Python, Pip, Virtual Env, Xcode on Mac

http://jessenoller.com/2009/03/16/so-you-want-to-use-python-on-the-mac/ Python with Xcode: I figured it out! The steps look lengthy but it's not that bad at all. Open Xcode 4. In the menu bar, click "File" -> "New" -> "New Project…". Select "Other" under "Mac OS X". Select "External Build System" and click "Next". Enter the product name. For the "Build Tool" field, type in "/usr/local/bin/python3" for Python 3 or "/usr/bin/python" for Python 2 without the quotes and then click "Next". Choose where to save it and click "Create". In the menu bar, click "File" -> "New" -> "New File…". Select "Other" under "Mac OS X". Select "Empty" and click "Next". Navigate to the project folder (it will not work, otherwise), enter the name of the Python file (include the ".py" ...

OAuth with tweepy

VIA:  https://github.com/tweepy/tweepy/blob/4799c740a20882e854a636e2721164cd5841a6c8/doc/auth_tutorial.rst OAuth Authentication OAuth is a bit trickier than basic auth, but there are some advantages to using it: You can set a 'from myappname' which will appear in tweets posted More secure since you don't need the user's password Your app does not break if the user changes their password in the future Tweepy tries to make OAuth as painless as possible for you. To begin the process we need to register our client application with Twitter. Create a new application and once you are done you should have your consumer token and secret. Keep these two handy, you'll need them. The next step is creating an OAuthHandler instance. Into this we pass our consumer token and secret which was given to us in the previous paragraph: auth = tweepy.OAuthHandler(consumer_token, consumer_secret) If you have a web application and are using a callback URL that needs to be supplied dy...

Tutorial: consuming Twitter's real-time stream API in Python

VIA:  http://arstechnica.com/open-source/guides/2010/04/tutorial-use-twitters-new-real-time-stream-api-in-python.ars/ import pycurl, json STREAM_URL = "http://chirpstream.twitter.com/2b/user.json" USER = "segphault" PASS = "XXXXXXXXX" def on_receive(data):   print data conn = pycurl.Curl() conn.setopt(pycurl.USERPWD, "%s:%s" % (USER, PASS)) conn.setopt(pycurl.URL, STREAM_URL) conn.setopt(pycurl.WRITEFUNCTION, on_receive) conn.perform()

[python] 'gcc-4.2' failed with exit status

Solution: add the following before the python command ARCHFLAGS="-arch i386 -arch x86_64" example: ARCHFLAGS="-arch i386 -arch x86_64" python setup.py build The Error occurs because the compiler tries to make the app for ppc architecture but after Xcode 4 the ppc compiler has been removed.

Rtree Python related posts

http://gissolved.blogspot.com/search/label/Rtree http://gaganb.wordpress.com/category/rtree/ http://pypi.python.org/pypi/Rtree/

MYSQL Python wrapper

http://www.zetcode.com/databases/mysqlpythontutorial/ nice tute for my sql python wrapper.

MySQL Mac and Python

I used MySQL dmg file to install MySQl and then the installation of python-mysqldb started failing. This is beacuse mac installation of mysql puts the config file in a non standard folder. Two ways to go about it. Either install mysql from source or use the tip on: http://blog.infoentropy.com/MySQL-python_EnvironmentError_mysql_config_not_found

[DRAFT] Installing and Deploying Celery on a Production Machine

This tutorial is not to teach you how to use celery, but a guide to deploying celery. I assume you have made a celery app and are familiar with the basics. The $ sign used here is to represent the command prompt and some of the commands might fail because of permission errors. I would suggest running them as sudo i.e by adding a "sudo" before them. Step 1: install celery $ easy_install Celery or if you have pip installed $ pip install Celery Step 2: Then put your python project in the a folder. I put mine in /opt/Myproject/ The project should have your celery configuration file "celeryconfig.py" and the project files that your config refers to. Step 3: At this stage you should $cd /opt/Myproject/ to the project folder and try out celery using the terminal. $celeryd you can define your options in the config file. For launch time options like starting celerybeat use $celeryd --help Step 4: If every thing is working fine you can start with deploying celery. Get the gen...