July 11, 2011

Install Django and MySQLdb along with Python

Most of the steps are straightforward. The only twisted place is the combination of mysql-python and the mysql itself. During my installation, there are two errors coming out:

1) "EnvironmentError: mysql_config not found" happened at the 1st place when I install mysql-python using the python install. The solution is to edit the file "setup_posix.py":
# mysql_config.path = "mysql_config"
mysql_config.path = "/usr/local/YOUR_LATEST_MYSQL_DIRECTORY/bin/mysql_config"
--Then, everything in the installation should be fine.


2) As I check the status of installation, I found some confusing info. popping up.
>>> import MySQLdb
Traceback (most recent call last):
  File "build/bdist.macosx-10.6-universal/egg/MySQLdb/__init__.py", line 19, in
  File "build/bdist.macosx-10.6-universal/egg/_mysql.py", line 7, in
  File "build/bdist.macosx-10.6-universal/egg/_mysql.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/creasywuqiong/.python-eggs/MySQL_python-1.2.3-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so, 2): Library not loaded: libmysqlclient.18.dylib
  Referenced from: /Users/creasywuqiong/.python-eggs/MySQL_python-1.2.3-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so
  Reason: image not found
>>>

The solution is to add some symbolic links:
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
sudo ln -s /usr/local/mysql/lib /usr/local/mysql/lib/mysql

Everything is fine:)
cheers~

References:
1) 2) 3)

No comments:

Post a Comment

Days of our lives

Daisypath Anniversary tickers