简体   繁体   中英

Installing MySQL-python on windows 7

Hey I tried installing MySQL-Python for abut 5 hours now but keep getting an error. at first it was "Unable to find vcvarsall.bat" and some thing abut me needing to have visual C++ 2010 . so after looking around I found a "solution" for my problem ... only to receive a new error when I pip install MySQL-Python.

I'm using python 3.4 with Pycharm The install is with pip on windows 7 .

This is what I get when I pip install

> 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\

you're going to want to add Python to your Path Environment Variable in this way. Go to:

  1. My Computer
  2. System Properties
  3. Advanced System Settings
  4. Under the "Advanced" tab click the button that says "Environment Variables"
  5. Then under System Variables you are going to want to add / change the following variables: PYTHONPATH and Path . Here is a paste of what my variables look like:

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

Your Path's might be different, so please adjust them, but this configuration works for me and you should be able to run MySQL after making these changes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM