Install Python 3 on CentOS 6

The latest release of Python 3 is 3.3.2, and there’s no package available on CentOS repo via yum. The following steps explains how to manually get Python 3 onto a CentOS system: Install development tools # yum groupinstall "Development Tools" # yum install zlib-devel bzip2-devel openssl-devel \ ncurses-devel sqlite-devel readline-devel tk-devel Download and install Python $ wget http://python.org/ftp/python/3.3.2/Python-3.3.2.tar.bz2 $ tar xjf Python-3.3.2.tar.bz2 $ cd Python-3.3.2 $ ./configure --prefix=/opt/python3 $ make $ make install</pre> Test ...

September 4, 2013 · 1 min · 81 words · kenno

Python MySQLdb package for Debian

I try to use MySQLdb module with my Python code for the first time. This is what I see: import MySQLdb Traceback (most recent call last): File "", line 1, in ImportError: No module named MySQLdb your code here For Debian, the package for MySQLdb module is python-mysqldb. # apt-get install python-mysqldb Now, let’s verify if MySQLdb module has been correctly installed: >>> import MySQLdb >>> No more import error message, which means you can start using MySQldb module now.

November 9, 2008 · 1 min · 80 words · kenno

Temperature Conversion v0.2

I just learned how to implement basic command-line argument with Python. Hence, I would like to incoporate this feature in the previous Temperature Conversion program. # convertc2f.py # Version: 0.2 # A program to convert Celsius temps to Fahrenheit # Date: 4/13/06 # by: S. San (Kenno)` import sys if (len(sys.argv) == 2): celsius = int(sys.argv[1]) else: celsius = int(input("What is the Celsius temperature? ")) fahrenheit = 9.0 / 5.0 * celsius + 32 print("The temparature is", fahrenheit, "degrees Fahrenheit.") Example with the command line argument: ...

April 13, 2006 · 1 min · 114 words · kenno

Temperature Conversion

If you get used to read the temperature in Fahrenheit scale like me, you may be confusing to see the temperature in Celsius scale given in weather forcasting on Australian or New Zealand televisions. So today, I’m gonna share a small Python program which can be used to convert the temperature scale from Fahrenheit to Celsius. As my Python programming skill is very limited at the moment, the program is going to perform very basic function. ...

April 6, 2006 · 1 min · 166 words · kenno