开发者

virtualenv pip mysqldb mac os X python

I tried this http://jazstudios.blogspot.com/2010/07/installing-mysql-python-mysqldb-in.html tip to install mysql-python (mysqldb) inside a virtualenv (named dogme). (this post point out 2 important things :

export ARCHFLAGS="-arch x86_64"
echo "mysql_config = /opt/local/bin/mysql_config5" >> ./dogme/build/MySQL-python/site.cfg

to help compile mysqldb)

but, when after, i run python, import MySQLdb, I get this :

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/.virtualenvs/dogme/lib/python2.5/site-packages/MySQLdb/__init__.py", line 19, in <module>
    import _mysql
ImportError: dlopen(/home/.virt开发者_开发问答ualenvs/dogme/lib/python2.5/site-packages/_mysql.so, 2): Symbol not found: _mysql_affected_rows
  Referenced from: /home/.virtualenvs/dogme/lib/python2.5/site-packages/_mysql.so
  Expected in: flat namespace
 in /home/.virtualenvs/dogme/lib/python2.5/site-packages/_mysql.so

anyone understand what's wrong ?


I had a similar problem, look my traceback:

>>> import MySQLdb
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.6/site-packages/MySQLdb/__init__.py", line 19, in <module>
    import _mysql
ImportError: dlopen(/Library/Python/2.6/site-packages/_mysql.so, 2): Library not loaded: libmysqlclient.16.dylib
  Referenced from: /Library/Python/2.6/site-packages/_mysql.so
  Reason: image not found

What I did was to put this variables in my .bash_profile:

export DYLD_LIBRARY_PATH="/usr/local/mysql/lib/:$DYLD_LIBRARY_PATH"

And when I ran a Python CGI application with Apache I set this same variable with SetEnv directive:

<Directory "/path/to/app">
    SetEnv DYLD_LIBRARY_PATH /usr/local/mysql/lib/:$DYLD_LIBRARY_PATH
    ...
</Directory>

And everything is working now.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜