Windows Python2.7 mysqldb installation error

天涯浪子 提交于 2019-12-01 15:55:56
Jayesh Vaghasiya

Download the pre-compiled whl file for mysql-python from from Christophe Gohlke’s Library of pre-compiled python packages for windows from the below location.

https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python

Now got to directory where you downloaded that file and open command prompt there.

Now run below command pip install xxx.whl

Best Luck !!

I got a same error.

I solved it by install mysql-connector

You can try...

   pip install mysqlclient==1.3.4

It worked for me.

If the above command doesn't work try this...

 pip install --only-binary :all: mysqlclient

both worked for me.

You can get a pre-compiled version from Christophe Gohlke’s Library of pre-compiled python packages for windows. Specifically, you can find the MySQL_python package here

Other alternatives would be to use a python distribution that comes with many packages pre-compiled and available for easy installation. Two examples are:

Sanju

You are missing Visual Studio C++ from your system or the correct environment for VS is not set properly based on the error in your question: "error: command 'C:\Program Files (x86)\Common Files\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe' failed with exit status 2"

Please check if you have C++ compiler installed at "C:\Program Files (x86)\Common Files\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe". If you do not have this installed it is available from Microsoft here: python27 Compiler

If you have VS installed try running the pip install from visual studio command prompt ,which generally would have all the environment created or try to run vcvarsall.bat from "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\" folder

Ashwin J Chhetri

Simply go to the site:

http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python

and download mysqlclient wheel file according to your python version and operating system bit specification, then install the downloaded file with typing

pip install downloaded_whl_file_name

Finally install mysqldb with command:

pip install flask-mysqldb

In my case I had to install mysql-connector with the same bitness as my python. So although I run 64bit windows 10, I have 32bit python 2.7 installed so I had to install 32bit mysql-connector from here to overcome the error.

The following action, mentioned above by zio, has solved my problem:

You can get a pre-compiled version from Christophe Gohlke’s Library of pre-compiled python packages for windows. Specifically, you can find the MySQL_python package here. After get the file, install it using pip install.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!