设置 MySQLdb 模块时出现问题

2023-11-29

我正在绞尽脑汁地尝试在我的 Mac 上设置 MySQLdb,以便连接到远程 MySQL 服务器。

  1. 我已经安装了最新的 C MySQL 客户端库
  2. 我已经安装了 XCode 4
  3. 我确实天真地尝试在安装 XCode 或客户端库之前安装该模块

我尝试通过在终端中运行以下命令来设置模块:

$ sudo python setup.py 构建

$ sudo python setup.py 安装

这两个命令都会失败并显示类似的错误消息。这是第一个堆栈跟踪:

running build
running build_py
copying MySQLdb/release.py -> build/lib.macosx-10.6-universal-2.6/MySQLdb
running build_ext
building '_mysql' extension
gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch ppc -arch x86_64 -pipe -Dversion_info=(1,2,3,'final',0) -D__version__=1.2.3 -I/usr/include/mysql -I/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c _mysql.c -o build/temp.macosx-10.6-universal-2.6/_mysql.o -fno-omit-frame-pointer -pipe
In file included from _mysql.c:36:
/usr/include/mysql/my_config.h:1030:2: warning: #warning defining SIZEOF_CHARP = 4
/usr/include/mysql/my_config.h:1044:2: warning: #warning defining SIZEOF_LONG = 4
/usr/libexec/gcc/powerpc-apple-darwin10/4.2.1/as: assembler (/usr/bin/../libexec/gcc/darwin/ppc/as or /usr/bin/../local/libexec/gcc/darwin/ppc/as) for architecture ppc not installed
Installed assemblers are:
/usr/bin/../libexec/gcc/darwin/x86_64/as for architecture x86_64
/usr/bin/../libexec/gcc/darwin/i386/as for architecture i386
In file included from _mysql.c:36:
/usr/include/mysql/my_config.h:1030:2: warning: #warning defining SIZEOF_CHARP = 4
/usr/include/mysql/my_config.h:1044:2: warning: #warning defining SIZEOF_LONG = 4
/usr/include/mysql/my_config.h:1151:1: warning: "WORDS_BIGENDIAN" redefined
In file included from /System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:8,
                 from pymemcompat.h:10,
                 from _mysql.c:29:
/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/pyconfig.h:1014:1: warning: this is the location of the previous definition
_mysql.c:2888: fatal error: error writing to -: Broken pipe
compilation terminated.
In file included from _mysql.c:36:
/usr/include/mysql/my_config.h:1027:2: warning: #warning defining SIZEOF_CHARP = 8
/usr/include/mysql/my_config.h:1041:2: warning: #warning defining SIZEOF_LONG = 8
lipo: can't open input file: /var/tmp//ccU6bipK.out (No such file or directory)
error: command 'gcc-4.2' failed with exit status 1

这是第二个命令的堆栈跟踪:

running install
running bdist_egg
running egg_info
writing MySQL_python.egg-info/PKG-INFO
writing top-level names to MySQL_python.egg-info/top_level.txt
writing dependency_links to MySQL_python.egg-info/dependency_links.txt
reading manifest file 'MySQL_python.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'MANIFEST'
warning: no files found matching 'ChangeLog'
warning: no files found matching 'GPL'
writing manifest file 'MySQL_python.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.6-universal/egg
running install_lib
running build_py
copying MySQLdb/release.py -> build/lib.macosx-10.6-universal-2.6/MySQLdb
running build_ext
building '_mysql' extension
gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch ppc -arch x86_64 -pipe -Dversion_info=(1,2,3,'final',0) -D__version__=1.2.3 -I/usr/include/mysql -I/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -c _mysql.c -o build/temp.macosx-10.6-universal-2.6/_mysql.o -fno-omit-frame-pointer -pipe
In file included from _mysql.c:36:
/usr/include/mysql/my_config.h:1030:2: warning: #warning defining SIZEOF_CHARP = 4
/usr/include/mysql/my_config.h:1044:2: warning: #warning defining SIZEOF_LONG = 4
/usr/libexec/gcc/powerpc-apple-darwin10/4.2.1/as: assembler (/usr/bin/../libexec/gcc/darwin/ppc/as or /usr/bin/../local/libexec/gcc/darwin/ppc/as) for architecture ppc not installed
Installed assemblers are:
/usr/bin/../libexec/gcc/darwin/x86_64/as for architecture x86_64
/usr/bin/../libexec/gcc/darwin/i386/as for architecture i386
In file included from _mysql.c:36:
/usr/include/mysql/my_config.h:1030:2: warning: #warning defining SIZEOF_CHARP = 4
/usr/include/mysql/my_config.h:1044:2: warning: #warning defining SIZEOF_LONG = 4
/usr/include/mysql/my_config.h:1151:1: warning: "WORDS_BIGENDIAN" redefined
In file included from /System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/Python.h:8,
                 from pymemcompat.h:10,
                 from _mysql.c:29:
/System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/pyconfig.h:1014:1: warning: this is the location of the previous definition
_mysql.c:2888: fatal error: error writing to -: Broken pipe
compilation terminated.
In file included from _mysql.c:36:
/usr/include/mysql/my_config.h:1027:2: warning: #warning defining SIZEOF_CHARP = 8
/usr/include/mysql/my_config.h:1041:2: warning: #warning defining SIZEOF_LONG = 8
lipo: can't open input file: /var/tmp//cchhckGP.out (No such file or directory)
error: command 'gcc-4.2' failed with exit status 1

我已经这样做了几天了,它开始让我发疯。任何帮助将不胜感激!


由于安装了新的、具有前瞻性的软件,您已经让自己陷入了头痛的境地Xcode 4而不是最新版本Xcode 3Mac OS X 10.6 就是随之发布的。您遇到的直接问题是 Python 尝试使用与 Python 本身构建相同的配置来构建 C 扩展模块。对于 10.6,包括三种架构:i386, x86_64, and ppc(为了与早期系统上构建的程序兼容)。显然Xcode 4已删除对构建的支持ppc拱门。你may能够通过使用轻松解决这个问题ARCHFLAGS环境变量,用于在构建扩展模块时覆盖 Python Distutils 使用的架构设置。尝试做这样的事情(未经测试,因为我手边没有 Xcode 4):

sudo bash
export ARCHFLAGS='-arch i386 -arch x86_64'
rm -r build
python setup.py build
python setup.py install

正如其他地方所推荐的,更好的解决方案是不要尝试使用系统 Python 和 MySQL 二进制安装程序在 10.6 上安装 MySQLdb。相反,通过像 MacPorts 这样的包管理器安装所有内容来使用完整的解决方案。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

设置 MySQLdb 模块时出现问题 的相关文章

随机推荐

  • 第二次调用表单时未处理表单加载事件

    为什么以下不起作用 两种形式 第一个调用第二个 第二个表单上有一个 DataGridView 它没有列 它们是由程序添加的 以及一个 DataGridViewButtonColumn 第一次调用 Form2 效果很好 但第二次调用它时 按钮
  • TextView 中有超链接文本

    我想在我的页面中添加一些文本作为超链接TextView就像下图一样 另外 与上图类似 我希望通过超链接打开相应的设置窗口 这怎么可能 编辑 为了让我的问题更具体 我想在单击这些文本时打开蜂窝设置 所以 我不知道在 String 对象中使用
  • S3 VPC 终端节点存储桶策略

    我有多个源自单个 VPC 的 EC2 实例 我想为我的 s3 分配一个存储桶策略 以确保仅允许该 VPC 流量访问该存储桶 因此我为该 VPC 创建了一个端点 并添加了所有路由表中的策略和路由 我向我的存储桶分配了以下策略 Version
  • 如何使用 Visual Basic 2010 Express Edition 编译 x64

    我发现了一个关于 Visual C 的论坛帖子 Visual C 2008 Express 版和 64 位目标 但是我如何在下面开发x64应用程序Visual Basic 2010 精简版 我没有安装 Visual Basic 2010 E
  • 动态更改 AWS CodePipeline 上的分支

    我正在寻找一个关于如何在 CodePipeline 中运行参数化 自定义 构建的良好解决方案 其中分支可以动态更改 关于这个问题的一些背景知识 我需要一个将在某个分支上启动的按需环境 我们已经使用 Bamboo CI 服务器作为基础设施的一
  • 使用 glBufferData 后可以删除浮点数组吗?

    我正在研究OpenGL API 我想问你是否可以在将浮点数组传递给OpenGL后删除它 示例代码 GLuint VBO float vertices new float 2 vertices 0 0 0f vertices 1 1 0f g
  • 使用浏览器后,Angular $location 不会更新

    有人遇到过这种行为吗 对此没有太多提及 其他帖子性质不同 这似乎与有关浏览器行为的文档不一致 当用户访问时 将 URL 与浏览器同步 更改地址栏 单击后退或前进按钮 或单击历史记录链接 单击链接 https docs angularjs o
  • 由于构建包错误,Heroku 未推送 Django 应用程序

    我正在尝试使用 Python 将 Django 项目上传到 Heroku 我的应用程序是基于 Python 3 6 1 构建的 当我将应用程序推送到 heroku 时 我在终端中收到以下错误消息 remote Compressing sou
  • 无法在 Windows 上设置 Anaconda:路径问题

    我一直在尝试在 Windows 8 1 上设置 Anaconda 1 8 但始终无法让 Windows 检测到它 我尝试通过编辑环境变量并添加将其添加到系统路径中C Anaconda 我尝试过 Cygwin 路线并尝试编辑 bashrc a
  • Typescript:为什么数组包含在数组联合类型上不起作用?

    我有以下类型 type Test roles nonProfit nonProfitPrivateDetails NonProfitPrivateDetails roles artist artistPrivateDetails Artis
  • 通过 JS 获取 style.display 属性仅在设置内联时才有效?

    我正在尝试获取页面上 div 的 DISPLAY 属性 我似乎只能抓住它 如果它是通过内联样式属性设置的 如果我的JS是这样的 alert document getElementById myDiv style display 它将使用以下
  • 在Python中设置颂歌

    如何在Python中设置以下具有相应初始条件的ode x t x t y t e t y t x t y t 2e t with x 0 1 and y 0 1 and 0 lt t lt 4 以下是我到目前为止所拥有的 def f u t
  • 无法抓取数据

    我刚刚开始使用 Google Apps 脚本 由于最佳编码实践建议使用尽可能少的工作表公式 因此我尝试使用 GAS Parser 进行网页抓取 然后将数据推送到我的电子表格中 在我的工作表中 使用以下公式返回一个数据表 这正是我从 GAS
  • 当我按以下方式修改 pandas 数据框时会发生什么

    试图理解这种行为 为什么会发生 如果是故意的 那么这样做的动机是什么 所以我创建了一个数据框 np random seed 0 df pd DataFrame np random random 4 2 0 1 0 0 548814 0 71
  • 我可以使用通用隐式或显式运算符吗? C#

    我如何更改以下语句 使其接受任何类型而不是 long 现在有一个问题 如果没有构造函数 我不希望它编译 因此 如果有一个字符串 长整型和双精度的构造函数 但没有布尔值 我如何让这一行适用于所有这些支持类型 ATM 我只是复制粘贴它 但如果我
  • 如何将 bash 脚本作为命令运行?

    我有一个 bash 脚本 用于配置无线访问媒体服务器中文本文件中的不同参数 该脚本位于一个目录中 因为我使用 putty 进行所有配置 所以我必须使用文件的完整路径或移动到包含该文件的目录 我想避免这种情况 是否可以保存 bash 脚本或编
  • Resque Mysql2::Error: 用户已超出“max_user_connections”资源(当前值:10)

    我在 Heroku 上运行 Resque 我的数据库是 ClearDB 我收到此错误 Mysql2 错误 用户 bdb2aedbee2c38 已超出 max user connections 资源 当前值 10 显示来自的完整字段proje
  • 如何在 JSF 2.0 中获取选项卡式窗格组件 (Sun Mojarra)

    我现在正在学习 使用 JSF 2 0 Sun Mojarra 我希望在我的 web 应用程序中有一个选项卡式窗格 单个选项卡可以命名为 General Detail1 Detail2 我该如何实现这一目标 到目前为止我还没有找到任何相关文档
  • MS Edge 不会将从 AJAX 请求返回的 cookie 保存在本地 HTML 文件中

    以下是我正在加载到 Microsoft Edge 中的本地文件的精简版本
  • 设置 MySQLdb 模块时出现问题

    我正在绞尽脑汁地尝试在我的 Mac 上设置 MySQLdb 以便连接到远程 MySQL 服务器 我已经安装了最新的 C MySQL 客户端库 我已经安装了 XCode 4 我确实天真地尝试在安装 XCode 或客户端库之前安装该模块 我尝试