IMDBPy安装mysqlclient失败-Python 2.7 Windows

IMDBPy安装mysqlclient失败-Python 2.7 Windows,python,mysql,python-2.7,pip,imdbpy,Python,Mysql,Python 2.7,Pip,Imdbpy,我以前是一名开发人员,但迄今为止还没有对Python做过多少工作。我试图在文本文件失效之前将完整的IMDB数据库放入MySQL服务器 我现在知道IMDBPy需要Python2.7(谢谢David!),所以我现在使用的是安装了Py2.7的干净机器。我的理解是,在成功运行imdbpy2sql脚本之前,我需要安装几个软件包 这些是: Python 2.7 MySQL(使用社区服务器5.7.2的最新版本) SQL对象 mysqlclient(需要用于Python的VC++编译器 (2.7) 我已经把

我以前是一名开发人员,但迄今为止还没有对Python做过多少工作。我试图在文本文件失效之前将完整的IMDB数据库放入MySQL服务器

我现在知道IMDBPy需要Python2.7(谢谢David!),所以我现在使用的是安装了Py2.7的干净机器。我的理解是,在成功运行imdbpy2sql脚本之前,我需要安装几个软件包

这些是:

  • Python 2.7
  • MySQL(使用社区服务器5.7.2的最新版本)
  • SQL对象
  • mysqlclient(需要用于Python的VC++编译器 (2.7)
我已经把所有东西安装到mysqlclient。当我尝试安装它时,它失败了,并显示一条消息,表明它找不到MySQL的\include文件夹

C:\Windows\system32>pip install -U SQLObject
Collecting SQLObject
  Downloading SQLObject-3.4.0-py2.py3-none-any.whl (1.7MB)
    100% |################################| 1.8MB 652kB/s
Collecting PyDispatcher>=2.0.4 (from SQLObject)
  Downloading PyDispatcher-2.0.5.tar.gz
Collecting FormEncode!=1.3.0,>=1.1.1 (from SQLObject)
  Downloading FormEncode-1.3.1.tar.gz (197kB)
    100% |################################| 204kB 3.3MB/s
Installing collected packages: PyDispatcher, FormEncode, SQLObject
  Running setup.py install for PyDispatcher ... done
  Running setup.py install for FormEncode ... done
Successfully installed FormEncode-1.3.1 PyDispatcher-2.0.5 SQLObject-3.4.0

C:\Windows\system32>pip install mysqlclient
Collecting mysqlclient
  Downloading mysqlclient-1.3.12.tar.gz (89kB)
    100% |################################| 92kB 837kB/s
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\\michael\\appdata\\local\\temp\\pip-build-jgsnac\\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\michael\appdata\local\temp\pip-uwgilx-record\install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-2.7
    copying _mysql_exceptions.py -> build\lib.win-amd64-2.7
    creating build\lib.win-amd64-2.7\MySQLdb
    copying MySQLdb\__init__.py -> build\lib.win-amd64-2.7\MySQLdb
    copying MySQLdb\compat.py -> build\lib.win-amd64-2.7\MySQLdb
    copying MySQLdb\connections.py -> build\lib.win-amd64-2.7\MySQLdb
    copying MySQLdb\converters.py -> build\lib.win-amd64-2.7\MySQLdb
    copying MySQLdb\cursors.py -> build\lib.win-amd64-2.7\MySQLdb
    copying MySQLdb\release.py -> build\lib.win-amd64-2.7\MySQLdb
    copying MySQLdb\times.py -> build\lib.win-amd64-2.7\MySQLdb
    creating build\lib.win-amd64-2.7\MySQLdb\constants
    copying MySQLdb\constants\__init__.py -> build\lib.win-amd64-2.7\MySQLdb\constants
    copying MySQLdb\constants\CLIENT.py -> build\lib.win-amd64-2.7\MySQLdb\constants
    copying MySQLdb\constants\CR.py -> build\lib.win-amd64-2.7\MySQLdb\constants
    copying MySQLdb\constants\ER.py -> build\lib.win-amd64-2.7\MySQLdb\constants
    copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win-amd64-2.7\MySQLdb\constants
    copying MySQLdb\constants\FLAG.py -> build\lib.win-amd64-2.7\MySQLdb\constants
    copying MySQLdb\constants\REFRESH.py -> build\lib.win-amd64-2.7\MySQLdb\constants
    running build_ext
    building '_mysql' extension
    creating build\temp.win-amd64-2.7
    creating build\temp.win-amd64-2.7\Release
    C:\Users\Michael\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Dversion_info=(1,3,12,'final',0) -D__version__=1.3.12 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.1\include" -Ic:\python27\include -Ic:\python27\PC /Tc_mysql.c /Fobuild\temp.win-amd64-2.7\Release\_mysql.obj /Zl
    _mysql.c
    _mysql.c(29) : fatal error C1083: Cannot open include file: 'mysql.h': No such file or directory
    error: command 'C:\\Users\\Michael\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\amd64\\cl.exe' failed with exit status 2

    ----------------------------------------
Command "c:\python27\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\michael\\appdata\\local\\temp\\pip-build-jgsnac\\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\michael\appdata\local\temp\pip-uwgilx-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in c:\users\michael\appdata\local\temp\pip-build-jgsnac\mysqlclient\

我已经确认了include文件夹以及它要查找的mysql.h文件(默认安装位置是“c:\Program Files\mysql\mysql Server 5.7\include”)。当我使用较新版本的Python(3)时,安装mysqlclient没有问题。因此,我假设MySQL的2.7版本和较新版本之间存在某种脱节。可能是需要更新的配置文件?如果有任何帮助,我们将不胜感激。

请先安装驱动程序,然后再试一次

  • 从以下链接下载并安装PythonMySQL连接器驱动程序。

  • pip安装MySQL-Python

  • 参考:

    能否在以管理员身份运行提示下重试同一命令
    pip install mysqlclient
    ?您看到的输出来自以管理员身份运行的命令提示。命令提示符窗口的文本标题为:“管理员:命令提示符”,感谢您的建议。我已成功安装了连接器。在查看了您建议的github线程之后,我将连接器文件夹从程序文件(parent+subs)复制到了程序文件(x86)(parent+subs),并按照建议将其重命名。运行“pip install MySQL Python”进行了大量复制,然后给了我错误“\u MySQL.c(42):致命错误C1083:无法打开include文件:'config win.h':没有这样的文件或目录”。从管理员命令提示符下运行。@DocMagro似乎在Windows环境中安装MySQL Python会很麻烦;这个答案可能有助于: