virtualenv pip mysqldb mac os X python

发布于 2024-10-16 18:20:39 字数 1064 浏览 3 评论 0原文

我尝试了这个 http://jazstudios.blogspot.com/ 2010/07/installing-mysql-python-mysqldb-in.html 提示在 virtualenv(名为 dogme)内安装 mysql-python (mysqldb)。 (这篇文章指出了两件重要的事情:

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

帮助编译 mysqldb)

但是,当我运行 python,导入 MySQLdb 时,我得到这个:

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/.virtualenvs/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

有人明白出了什么问题吗?

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/.virtualenvs/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 ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

落叶缤纷 2024-10-23 18:20:39

我遇到了类似的问题,请查看我的回溯:

>>> 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

我所做的是将这些变量放入我的 .bash_profile 中:

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

当我使用 Apache 运行 Python CGI 应用程序时,我使用 SetEnv 指令设置了相同的变量

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

:现在一切正常。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文