Category Archives: Python

pip – Check avaiable Python package version

It’s quite common to check the available versions of a Python package before installing it. The yolk3k package is a very convenient command line tool for querying PyPI and Python packages. yolk3k is a fork of the original yolk and it adds Python 3 support while maintaining Python 2 support.

 

1. Install the yolk3k package.

pip install yolk3k

Continue reading pip – Check avaiable Python package version

Windows – Install Python packages

Seems that it is very challenging to set up the Python environment properly on Windows. Python 3.4 ships with pip but if you want to install a older version of Python, there is not simple way for the package management.

If you get stuck on installing Python packages on your Windows machine, you could consider using the unofficial Python package binaries prepared by Christoph Gohlke.

Done =)

Python – Connect to MSSQL server using pymssql package

1. Install the pymssql package.

pip install pymssql

 

2. Create the your .py file.
test_mssql.py

import pymssql
conn = pymssql.connect(host='<host>', user='<username>', password='<password>', database='<dbname>')
cur = conn.cursor()

cur.execute('SELECT CONVERT(date, CURRENT_TIMESTAMP)')
row = cur.fetchone()
while row:
  print "CURRENT_TIMESTAMP=%s" % (row[0])
  row = cur.fetchone()

conn.close()

Continue reading Python – Connect to MSSQL server using pymssql package

Manage your Python projects with virtualenv

Last week we talked about managing multiple Pythons using pyenv.

 

But still we are lacking something like the Gemfile in Ruby for managing the version of those Python packages in a Python project. And here comes the Python virtualenv.

We can create different virtualenv on the same machine and each of them has its own Python binary, the pip package and the all other standard Python libraries needed to run the Python. In other words, each virtualenv acts like the Gemfile in a particular Python project.
Continue reading Manage your Python projects with virtualenv

Python – Install a Python2.5 on Ubuntu Lucid @ 2

Another way to install extra Python package is by source.

1. Install the build-essential and gcc.

  • sudo apt-get install build-essential gcc

 

2. Go to your target installation directory (usually i put them in /usr/local), download the source file.

Continue reading Python – Install a Python2.5 on Ubuntu Lucid @ 2

Python – Install a Python2.5 on Ubuntu Lucid @ 1

A few months ago i was working on a Drupal CDN setup using the Drupal CDN module and File Conveyor written by Wim Leers. But i have some problems when running the File Conveyor. At first, i thought it is because Python version. Ubuntu 10.04 (Lucid) comes with Python 2.6 but i wanna run the File Conveyor in 2.5. (*Finally i found that the switching the Python version would not resolve the problem.)

There are 2 ways to install additional Python package.
By apt-get Continue reading Python – Install a Python2.5 on Ubuntu Lucid @ 1