gpt4 book ai didi

osx-mountain-lion - python-mysqldb 再次找不到符号 : _mysql_affected_rows

转载 作者:行者123 更新时间:2023-12-02 03:44:27 26 4
gpt4 key购买 nike

我花了几天时间让 mysqldb 在 Snow Leopard 上工作,所以这一次我对操作系统进行了完全干净的安装,并仔细按照各种安装说明尝试让我的 django 开发环境正常工作。

brew install mysql 
sudo pip intall django
sudo pip install mysql-python

sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
export PATH=/usr/local/mysql/bin:$PATH
sudo export DYLD_LIBRARY_PATH=/usr/local/mysql/lib/

Mysql 和 django 工作正常,但如果我尝试导入 MySQLdb 或执行同步数据库,我会收到此错误:
Python 2.7.2 (default, Oct 11 2012, 20:14:37) 
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/MySQLdb/__init__.py", line 19, in <module>
import _mysql
ImportError: dlopen(/Library/Python/2.7/site-packages/_mysql.so, 2): Symbol not found: _mysql_affected_rows
Referenced from: /Library/Python/2.7/site-packages/_mysql.so
Expected in: flat namespace
in /Library/Python/2.7/site-packages/_mysql.so
>>>

现在已经用谷歌搜索了一天没有成功,真的需要回去工作!非常欢迎任何建议。

(也尝试在此处安装 mysql python-connector http://dev.mysql.com/downloads/connector/python/ 但没有 osx 版本,其他说明似乎暗示您需要适合您的 python 版本的正确版本,没有平台,所以我没有进一步追求。)

更新

干净地运行 brew doctor 在尝试 --universal 选项时遇到这些错误:
iMacs-iMac:~ phoebebr$ brew install -v  mysql --universal
==> Downloading http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.13.tar.gz/from/http://cdn.mysql.com/
Already downloaded: /Library/Caches/Homebrew/mysql-5.6.13.com
tar xf /Library/Caches/Homebrew/mysql-5.6.13.com
==> cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/mysql/5.6.13 -DMYSQL_DATADIR=/usr/local/var/mysql -DINSTALL_MANDIR=/usr/local/Cellar/mysql/5.6.13/share/man -DINSTALL_DOCDIR=/usr/local/Cellar/mysql/5.6.13/share/doc/mysql -DINSTALL_INFODIR=/usr/local/Cellar/mysql/5.6.13/share/info -DINSTALL_MYSQLSHAREDIR=share/mysql -DWITH_SSL=yes -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DSYSCONFDIR=/usr/local/etc -DWITH_UNIT_TESTS=OFF -DWITH_READLINE=yes -DCMAKE_OSX_ARCHITECTURES='i386;x86_64'
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/mysql/5.6.13 -DMYSQL_DATADIR=/usr/local/var/mysql -DINSTALL_MANDIR=/usr/local/Cellar/mysql/5.6.13/share/man -DINSTALL_DOCDIR=/usr/local/Cellar/mysql/5.6.13/share/doc/mysql -DINSTALL_INFODIR=/usr/local/Cellar/mysql/5.6.13/share/info -DINSTALL_MYSQLSHAREDIR=share/mysql -DWITH_SSL=yes -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DSYSCONFDIR=/usr/local/etc -DWITH_UNIT_TESTS=OFF -DWITH_READLINE=yes -DCMAKE_OSX_ARCHITECTURES='i386;x86_64'
-- Running cmake version 2.8.11.2
-- The C compiler identification is Clang 4.2.0
-- The CXX compiler identification is GNU 4.2.1
CMake Error at /usr/local/Cellar/cmake/2.8.11.2/share/cmake/Modules/Platform/Darwin.cmake:190 (message):
CMAKE_OSX_DEPLOYMENT_TARGET is '10.8' but CMAKE_OSX_SYSROOT:

""

is not set to a MacOSX SDK with a recognized version. Either set
CMAKE_OSX_SYSROOT to a valid SDK or set CMAKE_OSX_DEPLOYMENT_TARGET to
empty.
Call Stack (most recent call first):
/usr/local/Cellar/cmake/2.8.11.2/share/cmake/Modules/CMakeSystemSpecificInformation.cmake:36 (include)
CMakeLists.txt:99 (PROJECT)


-- Configuring incomplete, errors occurred!
==> Configuration
HOMEBREW_VERSION: 0.9.4
HEAD: b9b09cb1a620cd5ddafffc22d56a34e160bfc3f4
CPU: dual-core 64-bit penryn
OS X: 10.8.4-x86_64
Xcode: 4.6.3
CLT: 4.6.0.0.1.1365549073
X11: 2.7.4 => /opt/X11
==> ENV
CFLAGS: -Os -w -pipe
CXXFLAGS: -Os -w -pipe
LDFLAGS: -L/usr/local/lib
MAKEFLAGS: -j2
MACOSX_DEPLOYMENT_TARGET: 10.8
PKG_CONFIG_LIBDIR: /usr/local/lib/pkgconfig:/usr/local/Library/ENV/pkgconfig/10.8:/usr/lib/pkgconfig
OBJC: /usr/bin/clang
PATH: /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/Library/Contributions/cmd
CPATH: /usr/local/include

Error: mysql did not build
Logs: /Users/phoebebr/Library/Logs/Homebrew/mysql/CMakeCache.txt

确实发现这与 cmake 错误有关,但这确实超出了我的技术能力!
http://cmake.3232098.n2.nabble.com/OSX-deployment-target-confusion-for-2-8-10-td7582284.html
查看mysql站点,如何直接安装通用对我来说并不明显。

更新 2

这个页面很有用: Error importing MySQLdb in Python 2.7.2 on Mac OSx 10.8.1

所以再次安装了mysql而没有--universal并检查了所有内容的架构,如下所示:
iMacs-iMac:~ phoebebr$ which python
/usr/bin/python
iMacs-iMac:bin phoebebr$ file /usr/bin/python
/usr/bin/python: Mach-O universal binary with 2 architectures
/usr/bin/python (for architecture i386): Mach-O executable i386
/usr/bin/python (for architecture x86_64): Mach-O 64-bit executable x86_64

iMacs-iMac:mysql phoebebr$ which mysql
/usr/local/bin/mysql
iMacs-iMac:mysql phoebebr$ file /usr/local/bin/mysql
/usr/local/bin/mysql: Mach-O 64-bit executable x86_64

并且仍然收到相同的错误。
iMacs-iMac:~ phoebebr$ python
Python 2.7.2 (default, Oct 11 2012, 20:14:37)
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/MySQLdb/__init__.py", line 19, in <module>
import _mysql
ImportError: dlopen(/Library/Python/2.7/site-packages/_mysql.so, 2): Symbol not found: _mysql_affected_rows
Referenced from: /Library/Python/2.7/site-packages/_mysql.so
Expected in: flat namespace
in /Library/Python/2.7/site-packages/_mysql.so
>>>

最佳答案

这是一个 known Bug -- mysql-python 包目前仅针对 64 位构建。

关于osx-mountain-lion - python-mysqldb 再次找不到符号 : _mysql_affected_rows,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17920115/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com