This tutorial is mainly written because I want to try django1.2 today and need a runtime environment of Django. It also serves as a record to allow others to build the Django environment smoothly.
Before installation, make sure that the python environment has been configured in your system. The Python version I use is 2.6.2. This article installs django1.2.1, which requires a version later than python2.4.
Install Django
1. Download
You can download two stable versions as follows:
CD/usr/local/srcwget http://www.djangoproject.com/download/1.2.1/tarball/
The latest version, which needs to be downloaded directly from SVN:
SVN Co http://code.djangoproject.com/svn/django/trunk/
Note that subversion must be installed for the svn command. You can refer to the relevant tutorials and will not go into details here.
2. Installation
Tar xzvf Django-1.2.1.tar.gzcd Django-1.2.1python setup. py install
Here, Django is installed. At this time, the relevant Django module will install the site-packages folder in the python installation directory, and add the Django management script directory to the system environment variable.
Install mysql-Python
As the name suggests, MySQL-python is a class library used to access the MySQL database in Python. By default, Django uses this class library to access MySQL.
1. Download
Wget http://downloads.sourceforge.net/project/mysql-python/mysql-python-test/1.2.3c1/MySQL-python-1.2.3c1.tar.gz? Use_mirror = NCU
2. Modify the site. cfg file
Modifying the site. cfg folder mainly tells the myslq-Python module the path of the mysql_config file. Note that it is not the my. CNF file.
Remove the following line of configuration comments from the file and change "/usr/local/bin/mysql_config" to the path of the mysql_conf file in your system.
# Mysql_config =/usr/local/bin/mysql_config
3. Install
Tar zxvf MySQL-python-1.2.3c1.tar.gzcd MySQL-python-1.2.3c1python setup. py install
FAQs
1. The Python version is incorrect.
If there are multiple versions of python in the system, we recommend that you install Django and MySQL-python into a later version of Python. The method is to change python to pythonxx during installation, for example, python2.6.2. The installation command is:
Python26 setup. py install
2. libmysqlclient not found
When you start using MySQL-Python, you may encounter the following error:
Django. Core. Exceptions. improperlyconfigured: error loading mysqldb module: libmysqlclient_r.so.16: cannot open shared object file: no such file or directory
Solution: Copy libmysqlclient_r.so.16 under the "MySQL installation directory/lib/MySQL" to the "/usr/lib" directory.
3. Install mysql-python in Windows 64-bit environment
This is not the main content of this article. It is a supplement, and it is not written separately. Installing these tools on Windows is basically just a fool. However, you must download the appropriate installation file. Using a 32-bit installation file on a 64-bit system does not work for MySQL-Python. In order to avoid looking around, we will provide you with a link to different versions. Download the link based on your situation.
Finally, I would like to give you an aside. django1.2.1 is an efficient, convenient, flexible, and novel development model, which is truly amazing !! I don't know if the old brother can talk about how he feels.