DocMagro
DocMagro

Reputation: 33

IMDBPy installing mysqlclient fails - Python 2.7 Windows

I'm a former developer, but haven't done much with Python to date. I'm trying to get the full IMDB database into a MySQL server before the text files go poof.

I now know IMDBPy requires Python 2.7 (thanks David!) so I am on a clean machine with Py 2.7 installed. My understanding is that I need several packages installed before I can run the imdbpy2sql script successfully.

These are:

I have everything installed up to the mysqlclient. When I attempt to install it, it fails with a message that seems to indicate it cannot find the \include folder for MySQL.

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\

I have confirmed the include folder is there as well as the mysql.h file it is looking for (the default installation location was "c:\Program Files\MySQL\MySQL Server 5.7\include"). I didn't have a problem installing mysqlclient when I was using a newer version of Python (3). So I'm assuming there's some disconnect between the 2.7 version and newer versions of MySQL. Maybe a config file that needs to be updated? Any help would be appreciated.

Upvotes: 2

Views: 3137

Answers (1)

Mahesh Karia
Mahesh Karia

Reputation: 2055

Install driver first and then try if it works.

  1. Download & Install Python MySQL Connector driver from following link. https://dev.mysql.com/downloads/connector/c/6.0.html#downloads

  2. pip install MySQL-Python

Refer: https://github.com/PyMySQL/mysqlclient-python/issues/142

Upvotes: 1

Related Questions