read

I am a Python fan, I have being developing web sites for may years and never used it to this matter (PHP is very good for that!). Recently in my work with Canon, i had to migrate a web application from Django 1.2 to 1.4, so i learned it. And now i am in love with this agile-fast web framework. I am also using it to develop a new idea i am working on.

Enough said, here is how to install Django on Mountain Lion, for that you need the following, i am using MySQL for a DB:

  • MySQL
  • Python (not the 3 version)
  • MySQL-Python
  • Django

To avoid some restriction du to not being root, run the command and type your password :


sudo su

Now since MySQL is installed and Python, will just have to install MySQL for Python and make some configuration:

to install MySQL-Python type:

1
easy_install MySQL-python

Running smoothly untill booom:

1
EnvironmentError: mysql_config not found

Add MySQL to your path:

1
export PATH=$PATH:/usr/local/mysql/bin

Run easy_install again, and it should be good.

1
2
3
16 warnings generated.
zip_safe flag not set; analyzing archive contents...
Adding MySQL-python 1.2.4 to easy-install.pth file

Installed /Library/Python/2.7/site-packages/MySQL_python-1.2.4-py2.7-macosx-10.8-intel.egg
Processing dependencies for MySQL-python
Finished processing dependencies for MySQL-python

After this, you are good to go with MySQL for python, now lets test it with Djnago:

1
python manage.py createapp testApp

Edit your setting.py to put the DB credentials and add Django provided User and Admin Apps, now run:

1
python manage.py syncdb

Again another freaky error !

1
2
3
4
5
6
7
.egg-tmp/_mysql.so, 2): Library not loaded: libmysqlclient.18.dylib
Referenced from: /var/root/.python-eggs/MySQL_python-1.2.4-py2.7-macosx-10.8-intel.egg-tmp/_mysql.so
Reason: image not found
sh-3.2# python -c import MySQLdb
File "", line 1
import
^

Python can’t find mysqlclient, now in my mac i have mysql 5.5 and i found the file in:

1
/usr/local/mysql-5.5.34-osx10.6-x86_64/lib/libmysqlclient.

you have to update your DYLD_LIBRARY_PATH and add it, here is how:

1
DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/usr/local/mysql-5.5.34-osx10.6-x86_64/lib/

And that’s it, now you can run again

1
python manage.py syncdb

Hope this can help, if you have any questions, use the comment section to post them, i’ll answer them.

Nouri


Published on

Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *

E-Nouri

Full Stack Cloudiologist Mind

Back to Home