0

** Microsoft Visual C++ 10.0 is required. Get it with "Microsoft Windows SDK 7.1": www.microsoft.com/download/details.aspx?id=8279**

I am getting this error when i am installing mysqlclient or mysql-python

by pip install mysqlclient

i have updated everything and not using any of the visual studio produsct using sublime text please help me !

user7294879
  • 11
  • 1
  • 4
  • Have you installed the sdk from the link? – Solarflare Aug 20 '17 at 13:56
  • no it is for windows 7 but i have windows 10 – user7294879 Aug 20 '17 at 16:50
  • It doesn't matter. Most likely, _mysqlclient_ (or one of its dependencies?) doesn't come with binaries, but rather it's built from (_C_) sources at `pip install` time. In order to build _C_ code, you need a compiler. _Microsoft Visual C++ 10.0_ is the one used to build this module. It comes with _Microsoft Windows SDK 7.1_ (regardless of the (__newer__) _Win_ version that you're on). – CristiFati Aug 20 '17 at 17:45

1 Answers1

1

I wanted to test whether what I've stated in the comment is true, so I attempted pip installing MySQLClient in one of my Python 2.7.13 (VEnv) installations:

e:\Work\Dev\VEnvs\py2713x64-test>Scripts\pip.exe install -v mysqlclient
Config variable 'Py_DEBUG' is unset, Python ABI tag may be incorrect
Config variable 'WITH_PYMALLOC' is unset, Python ABI tag may be incorrect
Config variable 'Py_UNICODE_SIZE' is unset, Python ABI tag may be incorrect
Collecting mysqlclient
  1 location(s) to search for versions of mysqlclient:
  * https://pypi.python.org/simple/mysqlclient/
  Getting page https://pypi.python.org/simple/mysqlclient/
  Looking up "https://pypi.python.org/simple/mysqlclient/" in the cache
  No cache entry available
  Starting new HTTPS connection (1): pypi.python.org
  "GET /simple/mysqlclient/ HTTP/1.1" 200 2671
  Updating cache with response from 
  "https://pypi.python.org/simple/mysqlclient/"
  Caching b/c date exists and max-age > 0
  Analyzing links from page https://pypi.python.org/simple/mysqlclient/

  # @TODO - cfati: Truncated output

  No cache entry available
  "GET /packages/40/9b/0bc869f290b8f49a99b8d97927f57126a5d1befcf8bac92c60dc855f2523/mysqlclient-1.3.10.tar.gz HTTP/1.1" 200 82102
  Downloading mysqlclient-1.3.10.tar.gz (82kB)
  Downloading from URL https://pypi.python.org/packages/40/9b/0bc869f290b8f49a99b8d97927f57126a5d1befcf8bac92c60dc855f2523/mysqlclient-1.3.10.tar.gz#md5=e7fb95c4055e2d8a3322db5c85ab6fc8 (from https://pypi.python.org/simple/mysqlclient/)
    99% |############################### | 81kB 252kB/s eta 0:00:01  Updating cache with response from "https://pypi.python.org/packages/40/9b/0bc869f290b8f49a99b8d97927f57126a5d1befcf8bac92c60dc855f2523/mysqlclient-1.3.10.tar.gz"

  # @TODO - cfati: Truncated output

  running build_ext
  building '_mysql' extension
  error: Microsoft Visual C++ 9.0 is required. Get it from http://aka.ms/vcpython27
error
  Failed building wheel for mysqlclient

What is happening:

  • It connects to [PyPI]: Links for mysqlclient

  • It checks the latest version: v1.3.10 (at answer time)

  • Since this version is only compiled for Python 3.5 and Python 3.6 (064bit / 032bit):

    • mysqlclient-1.3.10-cp35-cp35m-win32.whl

    • mysqlclient-1.3.10-cp35-cp35m-win_amd64.whl

    • mysqlclient-1.3.10-cp36-cp36m-win32.whl

    • mysqlclient-1.3.10-cp36-cp36m-win_amd64.whl

  • It downloads the source archive: mysqlclient-1.3.10.tar.gz

  • The archive contains (besides the Python files, installation files and other additional files) a file: _mysql.c, which is the backend for communicating to MySQL. As I stated, in order to use the C code, it has to be compiled into a .dll (_mysql.pyd). For more info on building (compiling) C code, check [SO]: LNK2005 Error in CLR Windows Form (@CristiFati's answer)

  • Now, since the .dll will be loaded by Python when importing MySQLClient, it has to be compiled with the same compiler, or better: it must use the same C Runtime Library (UCRT) that Python ([Python.Wiki]: WindowsCompilers) uses (well it's not really a must, but using more than one UCRT in a process, is a recipe for disaster in 99.99% cases), it tries to build it with Microsoft Visual C++ 9.0 (or VStudio 2008), but it doesn't find it, and hence the error

The only thing that differs in your case it's the Microsoft Visual C++ 10.0 (or VStudio 2010) version, which tells me that you're using Python 3.3 or (most likely) Python 3.4.

Possible solutions:

CristiFati
  • 38,250
  • 9
  • 50
  • 87