Installing mysqlclient in Python 3.6 in windows - python

I want to install MySqlclient on my windows system. I am Currently using Python 3.6. After going through the various post over Stackoverflow, I could Not find the correct way.
This is what I have done so far:
1) Installation by using pip pip install mysqlclient. Error:
Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools" http://landinghub.visualstudio.com/visual-cpp-build-tools
I already have Microsoft Visual C++ installed on my laptop. Some are saying you need 2015 edition.
2) Installation by using wheel file pip install mysqlclient-1.3.13-cp36-cp36m-win_amd64.whl. Error:
Requirement mysqlclient-1.3.13-cp36-cp36m-win_amd64.whl looks like a filename, but the file does not exist.
mysqlclient-1.3.13-cp36-cp36m-win_amd64.whl is not a supported wheel on this platform.
2.1) Changing the whl file to different version pip install mysqlclient-1.3.13-cp36-cp36m-win32.whl. Error:
Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'C:\\Users\\Foxtrot\\Desktop\\finaltest\\mysqlclient-1.3.13-cp36-cp36m-win32.whl'
Other things that are done: updated setuptools, updated wheel.

Had the same problem, searched the web etc. Here this answer:
mysql-python install error: Cannot open include file 'config-win.h'
It has all the instructions. In short go to this site: https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient:
At that website you will find
mysqlclient‑1.3.13‑cp36‑cp36m‑win32.whl
mysqlclient‑1.3.13‑cp36‑cp36m‑win_amd64.whl
Download the correct file for your platform.
Then use your downloaded wheels file with pip and you're done:
pip install c:\mysqlclient‑1.3.13‑cp36‑cp36m‑win_amd64.whl
The https://www.lfd.uci.edu/~gohlke/pythonlibs has lots of lots of compiled libraries to solve the problem of building them from source yourself. They even compile them for python 3.7 :)
Alternative Solution
You can also download Visual C++ Build Tools and then you should be able to install every (at least to my knowledge) version of mysqlclient with pip.
To do this go to this site: https://www.scivision.co/python-windows-visual-c++-14-required/ there you can find out which version of Build Tools you need and you can also find a link to download the installer. Be aware though Build Tools require more than 4GB of free disk space.

Tell pip not to use sources and use binary packages instead:
pip install --only-binary :all: mysqlclient
https://pip.pypa.io/en/stable/reference/pip_install/#install-only-binary

I can't find mysqlclient-1.3.13's whl file on PyPi. So you need to compile it from source. Unfortunately it's not easy. I'm not Windows guy, so I only can recommend guide like this

I am using python3.7 on Windows 10 operating system.
I had same issue and after a long research I had installed it successfully.
Install "Microsoft Visual C++ Build Tools"
AND
My OS is having 64 bit operating system but still then it need to install 32 bit version
"mysqlclient‑1.4.2‑cp37‑cp37m‑win32.whl"
Download binary wheels from "https://www.lfd.uci.edu/~gohlke/pythonlibs/" and run command
pip install [path_to_downloaded_file] eg: C:\Users\Ds\mysqlclient-1.4.2-cp37-cp37m-win32.whl
use pipenv instead of pip if you are using virtual environment.

The error means that the package has not yet been compiled for your versions of OS and Python. So pip tries to build it from the source for you.
There are two possible solutions.
The first option is to install the most recent version of Microsoft Visual C++ Build Tools. Just go ahead and download it from the Microsoft website. Then pip should be able to compile the package.
Another option is using an unofficial binary. As mentioned here, a resource proved to be useful is https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python . Just download the pre-compiled package and install it using
pip install c:\path-to-a-pre-compiled-package

Had the same problem just day.
Tried to install mysqlclient on a Windows Server R2.
[...]
Tl;dr
"MySQL Connector C 6.1" was installed in the wrong directory: "C:\Program Files\MySQL" instead of "C:\Program Files (x86)\MySQL" where it should be for me.
--> Copied "MySQL Connector C 6.1" to "C:\Program Files (x86)\MySQL" Directory.
"C:\Users\MoBoo\AppData\Local\Temp" was Read-Only: Therefore pip couldn't compile files into Temp dir.
--> Allow Write access to "C:\Users\MoBoo\AppData\Local\Temp" Directory.

Here is what worked for me. I uninstalled mysql and re-installed it.
pip uninstall mysqlclient
Then simply re-install, so it picked the current version "1.4.2.post1"
pip install mysqlclient
Which interestingly, works straightaway.

for this error, most of user's suggest to install vs build but there is an alternative which works perfectly in my case and is sure for you too.
Download latest MySQL client from here
mysqlclients
Here you can see many version but prefer to download the latest one which has 32 bit and 64-bit files.
download theme and past the file on your projects root folder then run the same command but with the full file name of downloaded mysqlclient.
like: pip install mysqlclient‑1.4.6‑cp38‑cp38‑win32.whl
in my case, the file is this
also if have already the XAMPP server then you can use its PHPMyAdmin with python.
You just need to change on your roots setting.py file for this.
Something like this
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'mydjango',
'USER': 'root',
'PASSWORD':'',
'HOST':'localhost',
'PORT':'3306',
}
}
The port is the same which you see on xampp panel just before the start button of MySQL.
After changing this you just again start your server by hitting this command
python manage.py runserver
If you didn't see any error then congratulations you successfully connected with MySQL database.
Enjoy...

The easiest way to solve this problem is to download the correct version of MySQL client that supports the python version installed on your system.
MYSQLclient download link: https://pypi.org/project/mysqlclient/#files
Check the python version installed in your PC:

I was using Python version 3.7 and the same error was happening.
After trying all the possibilities, simply reinstalling the newest Python version (3.10.7 in my case) solved the issue.

Related

Flask-LDAP installation on windows box

I'm trying to set up single sign on using Python Flask on a windows box.
It looks like Flask-LDAP or Flask-Kerberos is what I should be using but I can't seem to install it using pip on a Windows box.
The installation fails with an error:
fatal error C1083: Cannot open include file: 'lber.h': No such file or directory
Does anyone have any experience doing this?
It's failing to install a prereq. I used Christoph Gohlke's python-ldap wheel to install python-ldap. Once python-ldap was installed, pip install Flask-LDAP ran successfully.
I don't use Flask-Kerberos, so I'm not sure which component fails to install there, but it likely has a similar resolution. Figure out which prereq is failing, find the unofficial Windows wheel for it, then try again with the prereq already installed.

in virtualenv, pip installing locally from source fails

I am trying to install a library in a virtualenv instance with pip. The library version I want (wxPython 3.0.2)
is not available on PyPi; it is only available for download from SourceForge. Thus, I have the source tarball downloaded on my machine and I am trying to install it in such a way that it will play nicely with virtualenv.
(I am on a Windows computer, running Python 2.7.)
I have tried the following:
doing a direct install: pip install wxPython-src-3.0.2.0.tar.bz2
extracting the files from the tarball to wxPython-src-3.0.2.0, then installing from the extracted directory: pip install wxPython-src-3.0.2.0
extracting the files from the tarball, then navigating into the extracted folder to the nested wxPython directory, which holds the setup.py file, and then installing from there: pip install wxPython
The last attempt seems the most promising, but I get the following traceback:
Processing \wxpython-src-3.0.2.0\wxpython
Complete output from command python setup.py egg_info:
Setuptools must be installed to build an egg
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in c:\users\__MY_USERNAME__\appdata\local\temp\pip-req-build-q0pxlt\
This is also strange, because it suggests I don't have setuptools even though I can run pip list and see version 40.6.3 installed.
Any help appreciated.
Why not install a precompiled version? There are a lot of .exe files at SF. You probably need wxPython3.0-win64-3.0.2.0-py27.exe.
Also take a look at Christoph Gohlke's collection.
If you still insist on installing from sources please bear in mind that wxPython 3 is so old it predates pip. Forget about pip.
First, you need to install wxWidgets as wxPython is just a Python wrapper for wxWidgets C++ library. Extract wxPython-src-3.0.2.0.tar.bz2 and follow instructions in wxPython-src-3.0.2.0/docs/msw/install.txt.
After compiling and installing wxWidgets compile wxPython. See wxPython-src-3.0.2.0/wxPython/docs/BUILD.txt.
My eventual solution was the easy way out: installing my package (wxPython) locally as #phd suggested, and opting for local package access via either virtualenv --system-site-packages env or deleting the "no-global-site-packages.txt" file in an existing environment folder.
Not what I expected to do, but it works so no complaints.

Pymssql Install Error

I'm trying to install FreeTDS using binaries from here, on Windows, but I can't figure out how to install binary files; a google search turned up nothing relevant. I'm installing so that the Python module Pymssql can be imported and used.
I'm getting the same error as in this post: https://github.com/pymssql/pymssql/issues/372
I fixed the problem by moving all the .h files from the FreeTDS and OpenSSL files I downloaded into where all the other .h files were in C:\Users\KAllen\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\include, and put all the .dll files with the others in C:\Users\KAllen\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\bin
You can download the Windows binaries here:
https://sourceforge.net/projects/freetdswindows/
There is an executable installer in the ZIP file you download; install away. It should install the necessary binaries you need. Good luck!
Download and install pymssql wheels from here:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#pymssql
Download and then pip install %userprofile%\downloads\pymssql-2.1.2-cp**-cp**m-win??.whl
conda install -c https://conda.anaconda.org/prometeia pymssql
WinPython may soon include pymssql by default:
https://github.com/winpython/winpython/issues/307

Install Python module paramiko on windows

I have been trying to install paramiko module on windows without success. I have been getting errors related to Visual C++ compiler missing. Is it possible to install paramiko without having to go through compile process.
Based on the method from this question this is what I would suggest (assuming you already have >=python-2.7.9 installed, if not, upgrade, 2.7.9 comes with pip, pre 2.7.9 doesn't):
Get the appropriate pycrypto whl file (based on python version and win32/win_amd64). I've found some available here (can't vouch for the site as I don't use python on windows much).
Run pip install pycrypto-stuff.whl (in a command prompt window in the directory where you've saved the pycrypto whl file).
Run pip install paramiko (in a command prompt, but can be in w/e folder you like).
That should do the trick. In general a simple pip install package_name would work, but pycrypto does not provide a wheel file (binary package), therefore you have to build it. By the sound of it you don't have Visual C++ installed (or not the right version, it only works for one, I don't recall which), pycrypto needs an extension package built to use the system crypto libraries, which is why the source package isn't working.
I was able to get it working by installing the following packages using pip.
pip install bcrypt cryptography pynacl paramiko
These were the packages my Linux install used as prerequisites, so they should work on windows as well.

PIP/easy_install PIL in Virtualenv vcvarsall.bat error Windows 7

So I know there's a fair amount of documentation on this already, but I just can't seem to get it to work. I'm deploying a Django app to Heroku, and am trying to install PIL into my virtualenv (a main part of the app requires user uploaded images).
I've tried both
easy_install PIL
and
pip install PIL
and everyone the installation ends in
error: Unable to find vcvarsall.bat.
How can I get PIL into my virtualenv? Can anyone walk me through it?
Thanks!
I don't know about Windows, but easy_install PIL does not work well.
easy_install pillow (compatible with setuptools) does the trick.
It will still need compilation if I remember correctly, and then you could have a look there : Unable to find vcvarsall.bat
PIL required make.exe or nmake.exe, you may need to install visual studio. vcvarsall.bat is part of visual c++. Please install binary package from http://www.lfd.uci.edu/~gohlke/pythonlibs/
As stated in other answers Pillow is the way to go since PIP is not compatible with setuptools.
So you may just do:
pip install pillow
Now, since you are working on windows you may run into compilation issues. You will need to install a gcc compiler in order for this to work. I just ran into this issue and blogged about this here.
To install Pillow
For this you need a compiler installed on computer, using Microsoft Visual Studio 9.0 (2008) Express Edition (Free). You need this c++ compiler for pillow to install.
Install from here
http://download.microsoft.com/download/A/5/4/A54BADB6-9C3F-478D-8657-93B3FC9FE62D/vcsetup.exe
open cmd prompt and enter the following
"C:\Program Files\Microsoft Visual Studio 9.0\Common7\Tools\vsvars32.bat"
this updates the PATH variable (no need for registry hacks, even in a virtualenv).
Because of firewall difficulties I usually pip install from a local directory
pip install -e c:\django\test_virtualenv\Pillow
Pillow must be the correction version for your O/S and computer architecture.

Categories

Resources