`
zl4393753
  • 浏览: 333541 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
社区版块
存档分类
最新评论

How to setup Django and MySQL-python on Mac OS X Lion

 
阅读更多
OriginalLink: http://decoding.wordpress.com/2012/01/23/how-to-setup-django-and-mysql-python-on-mac-os-x-lion/

Django is an excellent web-framework written in Python.

Here is a quick setup guide for installing Django and MySQL-python on Mac OS X Lion.

Setup Django

- Download latest Django here

- At this point I am assuming that you are familiar with the Terminal, so simply execute the following commands on your Downloads folder:

tar -xzvf Django-1.3.1.tar.gz
cd Django-1.3.1
sudo python setup.py install

Test Django installation

Type on the Terminal:

python
import django
print django.get_version()

Setup MySQL-python package

Download the latest MySQL (64-bit, tar archive) here

- Extract tar contents
- Rename folder to “mysql”
- Copy folder to /usr/local/
- You should now have mysql installed on /usr/local/mysql

Download the latest MySQL-python package here

Type on the Terminal:

tar -xvzf MySQL-python-1.2.3.tar.gz
cd MySQL-python-1.2.3

Edit site.cfg on your favorite text editor and change the mysql path as below: mysql_config = /usr/local/mysql/bin/mysql_config

You are now ready to build and install MySQL-python:

sudo python setup.py build
sudo python setup.py install

Edit your ~/.bash_profile, add the following line:

export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/

If you are already using MAMP you still have to follow the above MySQL installation process, as MAMP by default doesn’t include the required header files to build MySQL-python.
Moreover if you prefer MAMP, you don’t have to run mysql from /usr/local/mysql.
On your settings.py remember to set “127.0.0.1″ as your preferred db host in case that “localhost” doesn’t work.

Test MySQL-python installation

Restart Terminal and type:

python
import MySQLdb

If you are not getting any errors at this point, then you are all good to go!
I’d suggest starting from the Django’s excellent introductory tutorial.
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics