首页 文章

在Windows 7上安装MySQL-python

提问于
浏览
1

嘿,我现在尝试安装MySQL-Python约5个小时,但一直出错 . 起初它是“无法找到vcvarsall.bat”,并且有些东西需要有视觉C 2010 . 所以在环顾四周后,我找到了一个解决方案来解决我的问题...只是在我安装MySQL-Python时遇到一个新的错误 .

我正在使用Pycharm的python 3.4安装在Windows 7上的pip .

这是我在pip安装时得到的

> Collecting MySQL-python
  Using cached MySQL-python-1.2.5.zip
Building wheels for collected packages: MySQL-python
  Running setup.py bdist_wheel for MySQL-python: started
  Running setup.py bdist_wheel for MySQL-python: finished with status 'error'
  Complete output from command C:\Python34\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\yuval\\AppData\\Local\\Temp\\pycharm-packaging0.tmp\\MySQL-python\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d C:\Users\yuval\AppData\Local\Temp\tmp_8v3yxijpip-wheel- --python-tag cp34:
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win32-3.4
  copying _mysql_exceptions.py -> build\lib.win32-3.4
  creating build\lib.win32-3.4\MySQLdb
  copying MySQLdb\__init__.py -> build\lib.win32-3.4\MySQLdb
  copying MySQLdb\converters.py -> build\lib.win32-3.4\MySQLdb
  copying MySQLdb\connections.py -> build\lib.win32-3.4\MySQLdb
  copying MySQLdb\cursors.py -> build\lib.win32-3.4\MySQLdb
  copying MySQLdb\release.py -> build\lib.win32-3.4\MySQLdb
  copying MySQLdb\times.py -> build\lib.win32-3.4\MySQLdb
  creating build\lib.win32-3.4\MySQLdb\constants
  copying MySQLdb\constants\__init__.py -> build\lib.win32-3.4\MySQLdb\constants
  copying MySQLdb\constants\CR.py -> build\lib.win32-3.4\MySQLdb\constants
  copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-3.4\MySQLdb\constants
  copying MySQLdb\constants\ER.py -> build\lib.win32-3.4\MySQLdb\constants
  copying MySQLdb\constants\FLAG.py -> build\lib.win32-3.4\MySQLdb\constants
  copying MySQLdb\constants\REFRESH.py -> build\lib.win32-3.4\MySQLdb\constants
  copying MySQLdb\constants\CLIENT.py -> build\lib.win32-3.4\MySQLdb\constants
  warning: build_py: byte-compiling is disabled, skipping.

  running build_ext
  building '_mysql' extension
  creating build\temp.win32-3.4
  creating build\temp.win32-3.4\Release
  C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include" -IC:\Python34\include -IC:\Python34\include /Tc_mysql.c /Fobuild\temp.win32-3.4\Release\_mysql.obj /Zl
  _mysql.c
  _mysql.c(42) : fatal error C1083: Cannot open include file: 'config-win.h': No such file or directory
  error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\BIN\\cl.exe' failed with exit status 2

  ----------------------------------------
  Running setup.py clean for MySQL-python
Failed to build MySQL-python
Installing collected packages: MySQL-python
  Running setup.py install for MySQL-python: started
    Running setup.py install for MySQL-python: finished with status 'error'
    Complete output from command C:\Python34\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\yuval\\AppData\\Local\\Temp\\pycharm-packaging0.tmp\\MySQL-python\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record C:\Users\yuval\AppData\Local\Temp\pip-hqm_a4jr-record\install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build\lib.win32-3.4
    copying _mysql_exceptions.py -> build\lib.win32-3.4
    creating build\lib.win32-3.4\MySQLdb
    copying MySQLdb\__init__.py -> build\lib.win32-3.4\MySQLdb
    copying MySQLdb\converters.py -> build\lib.win32-3.4\MySQLdb
    copying MySQLdb\connections.py -> build\lib.win32-3.4\MySQLdb
    copying MySQLdb\cursors.py -> build\lib.win32-3.4\MySQLdb
    copying MySQLdb\release.py -> build\lib.win32-3.4\MySQLdb
    copying MySQLdb\times.py -> build\lib.win32-3.4\MySQLdb
    creating build\lib.win32-3.4\MySQLdb\constants
    copying MySQLdb\constants\__init__.py -> build\lib.win32-3.4\MySQLdb\constants
    copying MySQLdb\constants\CR.py -> build\lib.win32-3.4\MySQLdb\constants
    copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-3.4\MySQLdb\constants
    copying MySQLdb\constants\ER.py -> build\lib.win32-3.4\MySQLdb\constants
    copying MySQLdb\constants\FLAG.py -> build\lib.win32-3.4\MySQLdb\constants
    copying MySQLdb\constants\REFRESH.py -> build\lib.win32-3.4\MySQLdb\constants
    copying MySQLdb\constants\CLIENT.py -> build\lib.win32-3.4\MySQLdb\constants
    warning: build_py: byte-compiling is disabled, skipping.

    running build_ext
    building '_mysql' extension
    creating build\temp.win32-3.4
    creating build\temp.win32-3.4\Release
    C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include" -IC:\Python34\include -IC:\Python34\include /Tc_mysql.c /Fobuild\temp.win32-3.4\Release\_mysql.obj /Zl
    _mysql.c
    _mysql.c(42) : fatal error C1083: Cannot open include file: 'config-win.h': No such file or directory
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\VC\\BIN\\cl.exe' failed with exit status 2

    ----------------------------------------

  Failed building wheel for MySQL-python
Command "C:\Python34\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\yuval\\AppData\\Local\\Temp\\pycharm-packaging0.tmp\\MySQL-python\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record C:\Users\yuval\AppData\Local\Temp\pip-hqm_a4jr-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in C:\Users\yuval\AppData\Local\Temp\pycharm-packaging0.tmp\MySQL-python\

1 回答

  • 0

    您将要以这种方式将Python添加到Path Environment Variable . 去:

    • 我的电脑

    • 系统属性

    • 高级系统设置

    • 在"Advanced"选项卡下,单击显示"Environment Variables"的按钮

    • 然后在系统变量下,您将要添加/更改以下变量: PYTHONPATHPath . 这是我的变量看起来像的粘贴:

    PYTHONPATH

    C:\Python27;C:\Python27\Lib\site-packages;C:\Python27\Lib;C:\Python27\DLLs;C:\Python27\Lib\lib-tk;C:\Python27\Scripts
    

    Path

    C:\Program Files\MySQL\MySQL Utilities 1.3.5\;C:\Python27;C:\Python27\Lib\site-packages;C:\Python27\Lib;C:\Python27\DLLs;C:\Python27\Lib\lib-tk;C:\Python27\Scripts
    

    你的路径可能有所不同,所以请调整它们,但是这个配置适用于我,你应该能够在进行这些更改后运行MySQL .

相关问题