Category Archives: Python

Wednesday, 25 May, 2011

Cannot Import SQLite with Python 2.6 in Ubuntu Natty

I am compiling Python 2.6 on Ubuntu Natty. All the sqlite3 development headers and libraries are already installed.


$ make
.. .. ..
Failed to find the necessary bits to build these modules:
_bsddb _sqlite3 bsddb185
dbm gdbm sunaudiodev
zlib
To find the necessary bits, look in setup.py in detect_modules() for the module'
s name.

Failed to build these modules: crypt nis

After some checking, it turns out that the libsqlite3.so file is not in the /usr/lib dir, instead it is found in the /usr/lib/i386-linux-gnu dir. According to Barry Warsaw (The impact of multiarch on upstream Python), the .so files are moved to arch-specific directories, e.g. libsqlite3 to /usr/lib/x86_64-linux-gnu.  Ubuntu's Python packages broke because Python's build process does not look in the arch directories when it tries to figure out which extension modules it can build. There is a Python issue: Building Python on multiarch Debian and Ubuntu.

The easy solution is to create some symlinks in the /usr/lib dir:

$ cd /usr/lib
$ sudo ln -s i386-linux-gnu/libsqlite3.so.0.8.6 libsqlite3.so
$ sudo ln -s i386-linux-gnu/libz.so libz.so
$ sudo ln -s i386-linux-gnu/libcrypt.so libcrypt.so
$ sudo ln -s i386-linux-gnu/libnsl.so libnsl.so
After that, make will be able to compile those modules.

$ make
.. .. ..
Failed to find the necessary bits to build these modules:
_bsddb bsddb185 dbm
gdbm sunaudiodev
To find the necessary bits, look in setup.py in detect_modules() for the module'
s name.

$ sudo make install

Tags: Ubuntu, installation, Linux, Python


Posted in Python , Linux


Monday, 3 January, 2011

Books read in 2010

The Audacity of Hope by Barack Obama

Morita Therapy and the True Nature of Anxiety-based Disorders by Shoma Morita

Naikan: Gratitude, Grace, and the Japanese Art of Self-Reflection by Gregg Krech

The Five Wisdom Energies by Irini Rockwell

The Monk and the Philosopher by Jean-Francois Revel and Matthieu Ricard

Moon in a dewdrop, Dogen (partial) edited by Kazuaki Tanahashi

Start Where You Are (A guide to compassionate living) by Pema Chodron

Where is Your Buddha Nature? by Venerable Master Hsing Yun (translated by Tom Graham)

Teachings on Love by Thich Nhat Hanh

Old Path White Clouds by Thich Nhat Hanh

Who Ordered This Truckload of Dung? by Ajahn Brahm

Mindfulness, Bliss, And Beyond by Ajahn Brahm

Food For The Heart by Ajahn Chah

everything arises, everything falls away by Ajahn Chah

The Life of The Buddha by Bhikkhu Nanamoli

The Buddha's Ancient Path by Piyadassi Thera

The Great Discourse on Not-self by Venerable Mahasi Sayadaw

The Noble Eightfold Path: The Way to the End of Suffering by Bhikkhu Bodhi

In the Buddha's Words by Bhikkhu Bodhi 

Great Disciples of the Buddha by Nyanaponika Thera, Hellmuth Hecker (edited by Bhikkhu Bodhi)

The Buddha In The Jungle by Kamala Tiyavanich

Forest Recollections Wandering Monks in Twentieth-Century Thailand by Kamala Tiyavanich

Being Nobody, Going Nowhere by Ayya Khema

The Sound of Silence by Ajahn Sumedho

Joyful Wisdom by Yongey Mingyur Rinpoche with Eric Swanson

Smile at Fear by Chogyam Trungpa (edited by Carolyn Rose Gimian)

The Myth of Freedom by Chogyam Trungpa (edited by John Baker and Marvin Casper)

At Home In The Muddy Water by Ezra Bayda

Programming Google App Engine by Dan Sanderson

Expert Python Programming (partial) by Tarek Ziade

Crictor by Tomi Ungerer

Alice's Adventures in Wonderland by Lewis Carroll

The Illustrated Dharma Sutra by 蔡志忠

Full Metal Alchemist by Arakawa Hiromu

Tags: spiritual, zen, meditation, therapy, philosophy, history, book, story, gae, Python, Amazon, kindle, comic, 蔡志忠


Posted in Personal , Buddhism , Psychology , Python


Saturday, 6 March, 2010

Online task management application at OnesTodo.com

I have created OnesTodo at http://www.onestodo.com/ , it is a free online task management (todo list) web application hosted at Google App Engine.

The application shares the same principle and objectives that are described by David Allen's Getting Things Done. It is advisable to read his book first to understand the Getting Things Done (GTD) method.



The main objectives include:

  1. to capture one's tasks outside of one's mind,
  2. to discipline oneself to make decisions about these items,
  3. to write down the outcome of each item and determine the "next physical action" required to move the situation forward,
  4. to review the lists of actions regularly and complete them.
  • Tags: time-management, gtd, internet, Python, gae


    Posted in Personal , Python


    Saturday, 21 February, 2009

    Washington Times releases open source projects

    From Washington Times.

    The Washington Times has always focused on content. After careful review, we determined that the best way to have the top tools to produce and publish that content is to release the source code of our in-house tools and encourage collaboration.

    The source code is released under the permissive Apache License, version 2.0. The initial tools released are:

    • django-projectmgr, a source code repository manager and issue tracking application. It allows threaded discussion of bugs and features, separation of bugs, features and tasks and easy creation of source code repositories for either public or private consumption.

    • django-supertagging, an interface to the Open Calais service for semantic markup.

    • django-massmedia, a multi-media management application. It can create galleries with multiple media types within, allows mass uploads with an archive file, and has a plugin for fckeditor for embedding the objects from a rich text editor.

    • django-clickpass, an interface to the clickpass.com OpenID service that allows users to create an account with a Google, Yahoo!, Facebook, Hotmail or AIM account.

    The opensource.washingtontimes.com web site will be hosting the code and issue tracking software, using django-projectmgr.

    Tags: Python, django, resource, cooperation


    Posted in Open-Source , Python


    Monday, 11 February, 2008

    Sky Explorer Supports Unicode Filename

    Unicode filename and path are supported in version 1.0.3

    The symbian python os functions can accept utf8 string and will also return utf8 string (eg. in os.listdir). It does not use unicode string like in other native symbian functions.

    Since the Sky Explorer code uses path.join to get the full path in a lot of places, I modified path.join to always return in utf8 string regardless of its input. In places that use python os functions, no other changes are needed to allow for unicode filename and path. In places that use native symbian functions which expect unicode string, a conversion from utf8 string to unicode string is needed. -- unicode(fname, 'utf8')

    (in dir_util.py)

    # this replaces os.path.join (encode p in utf8)

    os_path_join = path.join

    def path_join(a, *p):

    return os_path_join((a and type(a) is unicode) and a.encode('utf8') or a,

    *[(type(d) is unicode) and d.encode('utf8') or d for d in p])

    if path.join is not path_join:

    path.join = path_join

    It will now support searching for unicode filename and can also search for unicode text in utf16 files.

    Zip and unzip can support unicode filename and path, this is done by encoding the unicode filename in utf8. Though if you unzip such a zip file in windows OS, the filename and path will remain in utf8 string.

    Unicode sms is supported using

    messaging.sms_send(to, msg, 'UCS2')

    Application tagging in unicode is also saved and restored correctly in the new version.

    (The source codes are released in http://skyexplorer.googlecode.com/svn/trunk/ )

    Feb 12, Download from http://skyexplorer.googlecode.com/svn/trunk/sis/skyexplorer_2ndEd_1.0.3.sis

    or

    http://skyexplorer.googlecode.com/files/skyexplorer_2ndEd_1.0.3.sis. (We're sorry page)

    Tags: Nokia, Sky-Explorer, unicode, Python


    Posted in Open-Source , Mobile , Sky-Explorer , Python


    Wednesday, 16 January, 2008

    SimCity Goes Open Source as Micropolis

    From ars technica.

    Will Wright's original SimCity has now gone open-source under the GNU General Public License. Though the name and some code have been changed due to EA's requirements, the core of the title remains intact and is now open for the public. This follows the inclusion of SimCity into the OLPC project.

    Originally written in C, the open-source version has been "recast into C++ classes, integrated into Python, using the wonderful SWIG interface generator tool." For tinkerers, a lot of the old bugs and code issues remain intact.

    The open-source version is now available on Don Hopkins' web site.

    One Laptop Per Child.

    Tags: simulation, Python, Game


    Posted in Game , Python , Open-Source


    Saturday, 27 October, 2007

    Python Script to Import Simple Tagging tags to Wordpress 2.3

    Wordpress 2.3 database now supports tags. For some reason, the Wordpress importer for Simple Tagging doesn't work for me, it imports only halfway.

    I wrote this python script stp-import.py to import the tags to Wordpress 2.3 database.

    [~]$ python stp-import.py

    The script will ask for the Wordpress database name, the database user and password, and the Wordpress database tables prefix (default is wp) to import the tags. Tested on my database.

    Database: dbname

    Database user: dbuser

    dbuser Password:

    Wordpress table prefix [wp]: wp

    215 tags imported.

    Tags: WordPress, Python, tagging


    Posted in Python , WordPress