pip install mysql-python fails with missing config-win.h - python

The python command is pip install mysql-python
The full error is _mysql.c(42): fatal error C1083: Cannot open include file: 'config-win.h': No such file or directory
Can someone please tell me how to fix this error?
What exactly is mysql-python and how is it different from regular mysql?
Another stack overflow post suggested installing it with a setup executable, where can I find this?
I installed something called mysql python connector from here:
https://downloads.mysql.com/archives/c-c/
It installed into C:\Program Files\MySQL\MySQL Connector C 6.1
However, I cannot find mysqld executable anywhere in this folder
Does this install mysql or do I actually need to install it from the Oracle website?

This required the full MySql server installation from Oracle

mysql-python is a module built for python-2 for interfacing with the mysql server so this does not include the mysql server and there is a fork of the same module called mysqlclient for python-3.
The reason for your error is you haven't installed Visual Studio 2019 to compile the c/c++ code in the python package. If you don't want to install Visual Studio 2019 check out these Python Wheel (.whl) files according to your python version
https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python (Python 2)
https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient (Python 3)

Related

Pip install results in this error " cl.exe' failed with exit code 2 "

I've read all of the other questions on this error and frustratingly enough, none give a solution that works.
If I run pip install sentencepiece in the cmd line, it gives me the following output.
src/sentencepiece/sentencepiece_wrap.cxx(2809): fatal error C1083: Cannot open include file: 'sentencepiece_processor.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.16.27023\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
[end of output]
I'm running python 3.10.1 and pip 22.0.3 .
*I have the following Microsoft Visual C++ programs on my windows machine,which I've just done a fresh install of as it was complaining of not having a particular C++ program.
MS VC++
I've even added the .exe file to my PATH variables but still I get the same error.
Am I missing a particular Microsoft program on my pc?
I haven't seen this problem in Windows, but for Linux, I would normally reinstall Python after installing the dependencies (such as the MSVC thing). In that case this is especially helpful because I'm often rebuilding (compiling and other related steps) Python/Pip.
Could also just be an error specific to the module and Python version combo you're trying.
From a discussion in the comments:
I have the pyenv-win version manager, so I was able to create venvs and test this for you. With Python 3.10.2, it fails; with Python 3.8.10, it's successful. So, yes, reinstalling does seem to be worthy of your time.
With python3.10
On Windows: First, install vcpkg and install sentencepiece:x64-windows-static
copy the header and lib files from vcpkg/installed/x64-windows-static/include and lib to
C:/Program Files/python310/build/root/include and lib
This should work as the setup.py install expects the library in a ..\build\root\lib directory.
As the C:\Program Files\python310\lib is in the /LIBPATH, the resulting ..\build\root\lib will point to the sentencepiece.lib
If still encounting errors, then set the INCLUDE and LIB environment variables so that the cl.exe , which is called from pip install sentencetransformers finds them.
People having windows+python 3.10 env, here are exact steps to install it via vcpkg.
Other instructions are covered in zweistein's answer.
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
./vcpkg install sentencepiece:x64-windows-static

django Failed to build mysqlclient [duplicate]

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.

Installting psycopg2 package for python 3.5 on unix

I am trying to install package psycopg2 to connect with postgres database but getting below error on running this command
python3.5 /usr/local/bin/psycopg2-2.7.3.2/setup.py install
*running build_ext
building 'psycopg2._psycopg' extension
creating build/temp.linux-x86_64-3.5
creating build/temp.linux-x86_64-3.5/psycopg
gcc*** command here
In file included from psycopg/psycopgmodule.c:27:
./psycopg/psycopg.h:30:2: error: #error "Psycopg requires PostgreSQL client library (libpq) >= 9.1"*
Current environment already have python 2.4, we installed another version 3.5. Now both versions are present.
Since there no direct connectivity with external net, I got the file for psycopg2 package and installing using setup.py
Please suggest, what I am missing here and how can I resolve this.
Note that cannot connect to internet as this is a close environment so cannot use PIP for installation of package. My main aim is to connect to postgres database.
The key here is
Psycopg requires PostgreSQL client library (libpq) >= 9.1
Make sure that the first pg_config on your PATH is from PostgreSQL version 9.1 or higher.
From the documentation:
Psycopg is a C wrapper around the libpq PostgreSQL client library. To install it from sources you will need:
The pg_config program: it is usually installed by the libpq-dev package but sometimes it is not in a PATH directory. Having it in the PATH greatly streamlines the installation, so try running pg_config --version

Error with simplejson dependency when installing Eve

I am new to Python and am trying to install Eve. I have Python 3.6.3 installed and am using pipenv. When I run pipenv install eve it fails with the error (here's an excerpt):
running build_ext
building 'simplejson._speedups' extension
error: [WinError 3] The system cannot find the path specified: 'C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v8.1\\lib'
_______________________________________
Error: An error occurred while installing eve!
Failed building wheel for simplejson
From what I can tell, this path is for the Windows 8.1 SDK.
What can I do to fix this? Do I need to install this SDK in order for simplejson to work? I don't really want to install this SDK, so why does simplejson need this?
I suspect that I don't actually need this SDK as I assume all of this can normally be executed in a Linux environment. Why would this dependency exist when executing on a Windows 7 machine as I am trying to do?
I found the answer. Yes, I do need the SDK. Windows compilers are required to "Install a non-pure Python package from sources with Pip" on Windows machines and are included in Microsoft Build Tools. More information can be found here: https://wiki.python.org/moin/WindowsCompilers

Scrapy: pip Install scrapy on windows 10 with python 3.6 and met Missing MSVCP140.dll file

When I install scrapy framework on PC I met the error "command 'cl.exe' failed no such file or directory" and after I fixed it by importing path of cl.exe in visual studio 14 and I won't see that error again (command 'cl.exe' failed no such file or directory) but I met a new error that talking about file MSVCP140.dll is missing.
Installation of Scrapy on Windows may facing error while installing Twisted.Use conda is a easy way to deal with it.
But if you want to use pip just following these step:
Download Twisted according to your Python and windows version on this site http://www.lfd.uci.edu/~gohlke/pythonlibs/#twisted
Turn to your download folder and pip install <downloaded filename>
pip install scrapy

Categories