gpt4 book ai didi

python - 无法安装mysql-python 无法构建或使用wheel

转载 作者:行者123 更新时间:2023-11-29 10:48:11 26 4
gpt4 key购买 nike

我正在尝试安装mysql-python,我在pip中尝试了两种方法

  1. python -m pip install mysql-python

    • 这不起作用说“Failed Building Wheel for MySQL-Python”
  2. 下载轮子 MySQL_python-1.2.5-cp27-none-win_amd64 和 MySQL_python-1.2.5-cp27-none-win32 并尝试使用命令单独安装它们python -m pip 安装文件名

    • 这并不适用于每种情况,并表示“此平台不支持”

有人知道出了什么问题以及如何安装 mysql-python 吗?

更新

自从写这篇文章以来,我仍然无法让 MySQLdb 正常工作,但我已经尝试了更多的方法。

1) 我正在使用Python 3.5 mysql-python 适用于Python 2.x,我应该一直尝试安装mysqlclient。然而,我现在遇到了与上面安装 mysqlclient 类似的问题,无论是使用轮子还是仅使用 pip。

> pip install mysqlclient




Collecting mysqlclient
Using cached mysqlclient-1.3.10.tar.gz
Installing collected packages: mysqlclient
Running setup.py install for mysqlclient ... error
Complete output from command c:\python27\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\teddy\\appdata\\local\\temp\\pip-build-lhtha0\\mysqlclient\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record c:\users\teddy\appdata\local\temp\pip-stnbio-record\install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build\lib.win32-2.7
copying _mysql_exceptions.py -> build\lib.win32-2.7
creating build\lib.win32-2.7\MySQLdb
copying MySQLdb\__init__.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\compat.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\connections.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\converters.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\cursors.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\release.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\times.py -> build\lib.win32-2.7\MySQLdb
creating build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\__init__.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\CLIENT.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\CR.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\ER.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\FLAG.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\REFRESH.py -> build\lib.win32-2.7\MySQLdb\constants
running build_ext
building '_mysql' extension
creating build\temp.win32-2.7
creating build\temp.win32-2.7\Release
C:\Users\teddy\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Dversion_info=(1,3,10,'final',0) -D__version__=1.3.10 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include" -Ic:\python27\include -Ic:\python27\PC /Tc_mysql.c /Fobuild\temp.win32-2.7\Release\_mysql.obj /Zl
_mysql.c
_mysql.c(29) : fatal error C1083: Cannot open include file: 'my_config.h': No such file or directory
error: command 'C:\\Users\\teddy\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\cl.exe' failed with exit status 2

----------------------------------------
Command "c:\python27\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\teddy\\appdata\\local\\temp\\pip-build-lhtha0\\mysqlclient\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record c:\users\teddy\appdata\local\temp\pip-stnbio-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in c:\users\teddy\appdata\local\temp\pip-build-lhtha0\mysqlclient\

2) 我尝试安装 MySQL 连接器 C。这没有改变任何东西。

3)我尝试让它在 Anaconda 附带的 IDE Spyder 上运行

谁能提出其他建议

最佳答案

我终于做到了。为了让它正常工作,我做了两件事:

  1. 我的 Pip 指向我电脑上旧版本的 Python电脑上,由于某种原因,Idle 可以拾取它,但不能拾取 Spyder。
  2. 我必须从以下位置移动 mysql 连接器文件之一:

C:\Program Files\MySQL 到 C:\Program Files (x86)\MySQL

关于python - 无法安装mysql-python 无法构建或使用wheel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44196101/

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