Tag 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

Perl – Setting locale failed

I tried to install Python using pyenv but came across the following error:

vagrant@vagrant-ubuntu-trusty-64:~$ pyenv install 2.7.8
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
	LANGUAGE = (unset),
	LC_ALL = (unset),
	LC_CTYPE = "UTF-8",
	LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").

 

For those which are unset, set the environmental variables in .bashrc or .bash_profile.

export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8

 

Re-login and try again.

Done =)

Reference: perl: warning: Please check that your locale settings ubuntu

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

Mongoose – Simple web server

Thanks my friend Mart who introduces reveal.js to me. It’s a great presentation framework and we used it for our Front End Web Development course in General Assembly.

Without the web development framework like Python Django or Ruby on Rails which bundle with pserver and WEBrick, i would like to find a light weight web server such that i could edit and preview my markdown which runs on reveal.js. Finally i find Mongoose.
Continue reading Mongoose – Simple web server

DumpCamp – Introduction to New Relic


In the 2nd DumpCamp meeting, Ronnie showed us a SAAS service called New Relic which provides Application Performance Management solution mainly for web applications and servers. It’s capabilities include but not limit to:
 

  • Performance analytics on Ruby, Rails, PHP, Java, .Net, Python applications
  • Real User Monitoring
  • Server Monitoring
  • SQL/NoSQL Performance Monitoring
  • Web Application Transaction Tracing

The Lite account is free and i tried it today. The setup is easy and straight forward. Just register an account online with some configurations on your web server through SSH. Then you could views your server and web application performance online.
Continue reading DumpCamp – Introduction to New Relic

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