I'm trying to install the python-ldap package with PyCharm and it is not working out, i get the following error:
Error Message:
Collecting python-ldap
Using cached https://files.pythonhosted.org/packages/7f/1c/28d721dff2fcd2fef9d55b40df63a00be26ec8a11e8c6fc612ae642f9cfd/python-ldap-3.1.0.tar.gz
Collecting pyasn1>=0.3.7 (from python-ldap)
Using cached https://files.pythonhosted.org/packages/a0/70/2c27740f08e477499ce19eefe05dbcae6f19fdc49e9e82ce4768be0643b9/pyasn1-0.4.3-py2.py3-none-any.whl
Collecting pyasn1_modules>=0.1.5 (from python-ldap)
Using cached https://files.pythonhosted.org/packages/e9/51/bcd96bf6231d4b2cc5e023c511bee86637ba375c44a6f9d1b4b7ad1ce4b9/pyasn1_modules-0.2.1-py2.py3-none-any.whl
Installing collected packages: pyasn1, pyasn1-modules, python-ldap
Running setup.py install for python-ldap: started
Running setup.py install for python-ldap: finished with status 'error'
Complete output from command C:\Users\Joan\PycharmProjects\prueba\venv\Scripts\python.exe -u -c "import setuptools, tokenize;file='C:\Users\Joan\AppData\Local\Temp\pycharm-packaging\python-ldap\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\Joan\AppData\Local\Temp\pip-record-y2ot_u84\install-record.txt --single-version-externally-managed --compile --install-headers C:\Users\Joan\PycharmProjects\prueba\venv\include\site\python3.6\python-ldap:
running install
running build
running build_py
creating build\lib.win-amd64-3.6
copying Lib\ldapurl.py -> build\lib.win-amd64-3.6
copying Lib\ldif.py -> build\lib.win-amd64-3.6
creating build\lib.win-amd64-3.6\ldap
copying Lib\ldap\async.py -> build\lib.win-amd64-3.6\ldap
copying Lib\ldap\asyncsearch.py -> build\lib.win-amd64-3.6\ldap
copying Lib\ldap\cidict.py -> build\lib.win-amd64-3.6\ldap
copying Lib\ldap\compat.py -> build\lib.win-amd64-3.6\ldap
copying Lib\ldap\constants.py -> build\lib.win-amd64-3.6\ldap
copying Lib\ldap\dn.py -> build\lib.win-amd64-3.6\ldap
copying Lib\ldap\filter.py -> build\lib.win-amd64-3.6\ldap
copying Lib\ldap\functions.py -> build\lib.win-amd64-3.6\ldap
copying Lib\ldap\ldapobject.py -> build\lib.win-amd64-3.6\ldap
copying Lib\ldap\logger.py -> build\lib.win-amd64-3.6\ldap
copying Lib\ldap\modlist.py -> build\lib.win-amd64-3.6\ldap
copying Lib\ldap\pkginfo.py -> build\lib.win-amd64-3.6\ldap
copying Lib\ldap\resiter.py -> build\lib.win-amd64-3.6\ldap
copying Lib\ldap\sasl.py -> build\lib.win-amd64-3.6\ldap
copying Lib\ldap\syncrepl.py -> build\lib.win-amd64-3.6\ldap
copying Lib\ldap__init__.py -> build\lib.win-amd64-3.6\ldap
creating build\lib.win-amd64-3.6\ldap\controls
copying Lib\ldap\controls\deref.py -> build\lib.win-amd64-3.6\ldap\controls
copying Lib\ldap\controls\libldap.py -> build\lib.win-amd64-3.6\ldap\controls
copying Lib\ldap\controls\openldap.py -> build\lib.win-amd64-3.6\ldap\controls
copying Lib\ldap\controls\pagedresults.py -> build\lib.win-amd64-3.6\ldap\controls
copying Lib\ldap\controls\ppolicy.py -> build\lib.win-amd64-3.6\ldap\controls
copying Lib\ldap\controls\psearch.py -> build\lib.win-amd64-3.6\ldap\controls
copying Lib\ldap\controls\pwdpolicy.py -> build\lib.win-amd64-3.6\ldap\controls
copying Lib\ldap\controls\readentry.py -> build\lib.win-amd64-3.6\ldap\controls
copying Lib\ldap\controls\sessiontrack.py -> build\lib.win-amd64-3.6\ldap\controls
copying Lib\ldap\controls\simple.py -> build\lib.win-amd64-3.6\ldap\controls
copying Lib\ldap\controls\sss.py -> build\lib.win-amd64-3.6\ldap\controls
copying Lib\ldap\controls\vlv.py -> build\lib.win-amd64-3.6\ldap\controls
copying Lib\ldap\controls__init__.py -> build\lib.win-amd64-3.6\ldap\controls
creating build\lib.win-amd64-3.6\ldap\extop
copying Lib\ldap\extop\dds.py -> build\lib.win-amd64-3.6\ldap\extop
copying Lib\ldap\extop__init__.py -> build\lib.win-amd64-3.6\ldap\extop
creating build\lib.win-amd64-3.6\ldap\schema
copying Lib\ldap\schema\models.py -> build\lib.win-amd64-3.6\ldap\schema
copying Lib\ldap\schema\subentry.py -> build\lib.win-amd64-3.6\ldap\schema
copying Lib\ldap\schema\tokenizer.py -> build\lib.win-amd64-3.6\ldap\schema
copying Lib\ldap\schema__init__.py -> build\lib.win-amd64-3.6\ldap\schema
creating build\lib.win-amd64-3.6\slapdtest
copying Lib\slapdtest_slapdtest.py -> build\lib.win-amd64-3.6\slapdtest
copying Lib\slapdtest__init__.py -> build\lib.win-amd64-3.6\slapdtest
running egg_info
writing Lib\python_ldap.egg-info\PKG-INFO
writing dependency_links to Lib\python_ldap.egg-info\dependency_links.txt
writing requirements to Lib\python_ldap.egg-info\requires.txt
writing top-level names to Lib\python_ldap.egg-info\top_level.txt
reading manifest file 'Lib\python_ldap.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
no previously-included directories found matching 'Doc.build'
writing manifest file 'Lib\python_ldap.egg-info\SOURCES.txt'
creating build\lib.win-amd64-3.6\slapdtest\certs
copying Lib\slapdtest\certs\README -> build\lib.win-amd64-3.6\slapdtest\certs
copying Lib\slapdtest\certs\ca.conf -> build\lib.win-amd64-3.6\slapdtest\certs
copying Lib\slapdtest\certs\ca.pem -> build\lib.win-amd64-3.6\slapdtest\certs
copying Lib\slapdtest\certs\client.conf -> build\lib.win-amd64-3.6\slapdtest\certs
copying Lib\slapdtest\certs\client.key -> build\lib.win-amd64-3.6\slapdtest\certs
copying Lib\slapdtest\certs\client.pem -> build\lib.win-amd64-3.6\slapdtest\certs
copying Lib\slapdtest\certs\gencerts.sh -> build\lib.win-amd64-3.6\slapdtest\certs
copying Lib\slapdtest\certs\gennssdb.sh -> build\lib.win-amd64-3.6\slapdtest\certs
copying Lib\slapdtest\certs\server.conf -> build\lib.win-amd64-3.6\slapdtest\certs
copying Lib\slapdtest\certs\server.key -> build\lib.win-amd64-3.6\slapdtest\certs
copying Lib\slapdtest\certs\server.pem -> build\lib.win-amd64-3.6\slapdtest\certs
warning: build_py: byte-compiling is disabled, skipping.
running build_ext
building '_ldap' extension
creating build\temp.win-amd64-3.6
creating build\temp.win-amd64-3.6\Release
creating build\temp.win-amd64-3.6\Release\Modules
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -DHAVE_SASL -DHAVE_TLS -DHAVE_LIBLDAP_R -DHAVE_LIBLDAP_R -DLDAPMODULE_VERSION=3.1.0 "-DLDAPMODULE_AUTHOR=python-ldap project" "-DLDAPMODULE_LICENSE=Python style" -IModules -IC:\Users\Joan\PycharmProjects\prueba\venv\include -IC:\Users\Joan\AppData\Local\Programs\Python\Python36\include -IC:\Users\Joan\AppData\Local\Programs\Python\Python36\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /TcModules/LDAPObject.c /Fobuild\temp.win-amd64-3.6\Release\Modules/LDAPObject.obj
LDAPObject.c
c:\users\joan\appdata\local\temp\pycharm-packaging\python-ldap\modules\constants.h(7): fatal error C1083: Cannot open include file: 'lber.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2
----------------------------------------
Command "C:\Users\Joan\PycharmProjects\prueba\venv\Scripts\python.exe -u -c "import setuptools, tokenize;file='C:\Users\Joan\AppData\Local\Temp\pycharm-packaging\python-ldap\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\Joan\AppData\Local\Temp\pip-record-y2ot_u84\install-record.txt --single-version-externally-managed --compile --install-headers C:\Users\Joan\PycharmProjects\prueba\venv\include\site\python3.6\python-ldap" failed with error code 1 in C:\Users\Joan\AppData\Local\Temp\pycharm-packaging\python-ldap\
I'll appreciate all the help,
thank you in advance!
To correct the error due to dependencies to install the python-ldap
download the wheel file
http://www.lfd.uci.edu/~gohlke/pythonlibs/#python-ldap
python 3.6 is suitable with
python_ldap-3.2.0-cp36-cp36m-win_amd64.whl
Deploy the file in c:\python36\Scripts\
install it with
python -m pip install python_ldap-3.2.0-cp36-cp36m-win_amd64.whl
For Windows what it worked for me in this case after tried many options was:
python -m pip install --only-binary :all: ldap
It's because pip tries to compile OpenLDAP library and python-ldap is just a wrapper around binary lib. If you don't want to compile OpenLDAP library by yourself then I recommend this site:
https://www.lfd.uci.edu/~gohlke/pythonlibs/
Download wheel-file you need, according to python version you use, for example python_ldap-3.2.0-cp37-cp37m-win_amd64.whl is for Python 3.6 64bit.
Then install:
python -m pip install python_ldap-3.2.0-cp37-cp37m-win_amd64.whl
From the Python LDAP documentation you can see that it requires a series of packages in order to get a proper installation (pre-build requisites). The commands you need to run, depends on the OS.
Sadly, this is intended for Linux based OS's.
I hope it helps! Cheers
Related
When I am trying to install PyGObject I get an error. I am using Python 3.10 and Windows Command Prompt.
C:\windows\system32>pip install PyGObject
Collecting PyGObject
Using cached PyGObject-3.42.1.tar.gz (718 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: pycairo>=1.16.0 in c:\users\mona.hynes.lisdoon\appdata\local\programs\python\python310\lib\site-packages (from PyGObject) (1.21.0)
Building wheels for collected packages: PyGObject
Building wheel for PyGObject (pyproject.toml) ... error
error: subprocess-exited-with-error
× Building wheel for PyGObject (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [48 lines of output]
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win-amd64-cpython-310
creating build\lib.win-amd64-cpython-310\pygtkcompat
copying pygtkcompat\generictreemodel.py -> build\lib.win-amd64-cpython-310\pygtkcompat
copying pygtkcompat\pygtkcompat.py -> build\lib.win-amd64-cpython-310\pygtkcompat
copying pygtkcompat\__init__.py -> build\lib.win-amd64-cpython-310\pygtkcompat
creating build\lib.win-amd64-cpython-310\gi
copying gi\docstring.py -> build\lib.win-amd64-cpython-310\gi
copying gi\importer.py -> build\lib.win-amd64-cpython-310\gi
copying gi\module.py -> build\lib.win-amd64-cpython-310\gi
copying gi\pygtkcompat.py -> build\lib.win-amd64-cpython-310\gi
copying gi\types.py -> build\lib.win-amd64-cpython-310\gi
copying gi\_constants.py -> build\lib.win-amd64-cpython-310\gi
copying gi\_error.py -> build\lib.win-amd64-cpython-310\gi
copying gi\_gtktemplate.py -> build\lib.win-amd64-cpython-310\gi
copying gi\_option.py -> build\lib.win-amd64-cpython-310\gi
copying gi\_ossighelper.py -> build\lib.win-amd64-cpython-310\gi
copying gi\_propertyhelper.py -> build\lib.win-amd64-cpython-310\gi
copying gi\_signalhelper.py -> build\lib.win-amd64-cpython-310\gi
copying gi\__init__.py -> build\lib.win-amd64-cpython-310\gi
creating build\lib.win-amd64-cpython-310\gi\repository
copying gi\repository\__init__.py -> build\lib.win-amd64-cpython-310\gi\repository
creating build\lib.win-amd64-cpython-310\gi\overrides
copying gi\overrides\Gdk.py -> build\lib.win-amd64-cpython-310\gi\overrides
copying gi\overrides\GdkPixbuf.py -> build\lib.win-amd64-cpython-310\gi\overrides
copying gi\overrides\GIMarshallingTests.py -> build\lib.win-amd64-cpython-310\gi\overrides
copying gi\overrides\Gio.py -> build\lib.win-amd64-cpython-310\gi\overrides
copying gi\overrides\GLib.py -> build\lib.win-amd64-cpython-310\gi\overrides
copying gi\overrides\GObject.py -> build\lib.win-amd64-cpython-310\gi\overrides
copying gi\overrides\Gtk.py -> build\lib.win-amd64-cpython-310\gi\overrides
copying gi\overrides\keysyms.py -> build\lib.win-amd64-cpython-310\gi\overrides
copying gi\overrides\Pango.py -> build\lib.win-amd64-cpython-310\gi\overrides
copying gi\overrides\__init__.py -> build\lib.win-amd64-cpython-310\gi\overrides
running build_ext
pycairo: new API
pycairo: trying include directory: 'C:\\Users\\mona.hynes.LISDOON\\AppData\\Local\\Temp\\pip-build-env-6iivyiiw\\overlay\\Lib\\site-packages\\cairo\\include'
pycairo: found 'C:\\Users\\mona.hynes.LISDOON\\AppData\\Local\\Temp\\pip-build-env-6iivyiiw\\overlay\\Lib\\site-packages\\cairo\\include\\py3cairo.h'
building 'gi._gi' extension
creating build\temp.win-amd64-cpython-310
creating build\temp.win-amd64-cpython-310\Release
creating build\temp.win-amd64-cpython-310\Release\gi
"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -DPY_SSIZE_T_CLEAN -IC:\Users\mona.hynes.LISDOON\AppData\Local\Temp\pip-install-zi8f2b72\pygobject_c02dc4480e0747d4bcd87d8b59ba11df -IC:\Users\mona.hynes.LISDOON\AppData\Local\Temp\pip-install-zi8f2b72\pygobject_c02dc4480e0747d4bcd87d8b59ba11df\gi -IC:\Users\mona.hynes.LISDOON\AppData\Local\Programs\Python\Python310\include -IC:\Users\mona.hynes.LISDOON\AppData\Local\Programs\Python\Python310\Include "-IC:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\ATLMFC\include" "-IC:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.31.31103\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\\shared" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\\um" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\\winrt" "-IC:\Program Files (x86)\Windows Kits\10\\include\10.0.19041.0\\cppwinrt" /Tcgi\gimodule.c /Fobuild\temp.win-amd64-cpython-310\Release\gi\gimodule.obj -FImsvc_recommended_pragmas.h
gimodule.c
gi\gimodule.c: fatal error C1083: Cannot open include file: 'msvc_recommended_pragmas.h': No such file or directory
error: command 'C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.31.31103\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for PyGObject
Failed to build PyGObject
ERROR: Could not build wheels for PyGObject, which is required to install pyproject.toml-based projects
I had the same issue and the problem is that PyGObject needs to be compiled which will be done by default using Microsoft Visual Studio. This seems not to work. I also read somewhere that this won't work.
I managed to compile it using the instructions on https://pygobject.readthedocs.io/en/latest/getting_started.html but then got errors importing it into my project ('circular import'). Msys2 relies on python 3.9 by default, while I'm using 3.10. Could be related. Did not have time to look further, yet. So I'm happy for solutions to that :) Maybe will try changing to 3.9. later.
try install mysql-python
C:\Users\Одиночка>pip install mysql-python
Collecting mysql-python
Using cached MySQL-python-1.2.5.zip
Installing collected packages: mysql-python
Running setup.py install for mysql-python ... error
Complete output from command c:\python27\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\2871~1\\appdata\\local\\temp\\pip-build-lyj5ba\\mysql-python\\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\2871~1\appdata\local\temp\pip-y0f9do-record\install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build\lib.win32-2.7
copying _mysql_exceptions.py -> build\lib.win32-2.7
creating build\lib.win32-2.7\MySQLdb
copying MySQLdb\__init__.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\converters.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\connections.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\cursors.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\release.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\times.py -> build\lib.win32-2.7\MySQLdb
creating build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\__init__.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\CR.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\ER.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\FLAG.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\REFRESH.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\CLIENT.py -> build\lib.win32-2.7\MySQLdb\constants
running build_ext
building '_mysql' extension
creating build\temp.win32-2.7
creating build\temp.win32-2.7\Release
cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include" -Ic:\python27\include -Ic:\python27\PC /Tc_mysql.c /Fobuild\temp.win32-2.7\Release\_mysql.obj /Zl
error: command 'cl.exe' failed: No such file or directory
I've met this problem too. And I tried the methods listed in Internet and not work. Either install Microsoft Visual Studio with cl.exe in computer or add C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin" to PATH. Just didn't work for me. Then as there's error shows in the middle of the error mesg:
error: command 'cl.exe' failed: No such file or directory
.---------------------------------------- Failed building wheel for
Twisted Running setup.py clean for Twisted Failed to build Twisted
It mentioned Twisted, so I install Twisted first and it worked.
You can install the correct version of Twisted in below link:
Unofficial Windows Binaries for Python Extension Packages
I'm using Python 2.7 and Django 1.9.4. I want to integrate my Django application with MySQL 5.7 database and I executed:
pip install MySQL-python
on Windows 7 machine 64-bit.
And getting Error :
F:\Djangoproject\mysite>pip install MySQL-python
Collecting MySQL-python
Using cached MySQL-python-1.2.5.zip
Building wheels for collected packages: MySQL-python
Running setup.py bdist_wheel for MySQL-python ... error
Complete output from command c:\python27\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\chandra\\appdata\\local\\temp\\pip-build
-3qbbxo\\MySQL-python\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__
, 'exec'))" bdist_wheel -d c:\users\chandra\appdata\local\temp\tmpoytuplpip-wheel- --python-tag cp27:
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win32-2.7
copying _mysql_exceptions.py -> build\lib.win32-2.7
creating build\lib.win32-2.7\MySQLdb
copying MySQLdb\__init__.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\converters.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\connections.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\cursors.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\release.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\times.py -> build\lib.win32-2.7\MySQLdb
creating build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\__init__.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\CR.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\ER.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\FLAG.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\REFRESH.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\CLIENT.py -> build\lib.win32-2.7\MySQLdb\constants
running build_ext
building '_mysql' extension
creating build\temp.win32-2.7
creating build\temp.win32-2.7\Release
C:\Users\Chandra\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Dversion_info
=(1,2,5,'final',1) -D__version__=1.2.5 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include" -Ic:\python27\include -Ic:\python27\PC /Tc_mys
ql.c /Fobuild\temp.win32-2.7\Release\_mysql.obj /Zl
_mysql.c
_mysql.c(42) : fatal error C1083: Cannot open include file: 'config-win.h': No such file or directory
error: command 'C:\\Users\\Chandra\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\cl.exe' failed with exit statu
s 2
----------------------------------------
Failed building wheel for MySQL-python
Running setup.py clean for MySQL-python
Failed to build MySQL-python
Installing collected packages: MySQL-python
Running setup.py install for MySQL-python ... error
Complete output from command c:\python27\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\chandra\\appdata\\local\\temp\\pip-bui
ld-3qbbxo\\MySQL-python\\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\chandra\appdata\local\temp\pip-rskyc7-record\install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build\lib.win32-2.7
copying _mysql_exceptions.py -> build\lib.win32-2.7
creating build\lib.win32-2.7\MySQLdb
copying MySQLdb\__init__.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\converters.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\connections.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\cursors.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\release.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\times.py -> build\lib.win32-2.7\MySQLdb
creating build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\__init__.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\CR.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\ER.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\FLAG.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\REFRESH.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\CLIENT.py -> build\lib.win32-2.7\MySQLdb\constants
running build_ext
building '_mysql' extension
creating build\temp.win32-2.7
creating build\temp.win32-2.7\Release
C:\Users\Chandra\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Dversion_in
fo=(1,2,5,'final',1) -D__version__=1.2.5 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include" -Ic:\python27\include -Ic:\python27\PC /Tc_m
ysql.c /Fobuild\temp.win32-2.7\Release\_mysql.obj /Zl
_mysql.c
_mysql.c(42) : fatal error C1083: Cannot open include file: 'config-win.h': No such file or directory
error: command 'C:\\Users\\Chandra\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\cl.exe' failed with exit sta
tus 2
----------------------------------------
Command "c:\python27\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\chandra\\appdata\\local\\temp\\pip-build-3qbbxo\\MySQL-python\
\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\chandra\appdata\local\temp\pip-rskyc7-record\install-record.txt --single-version-externally-managed --compile" failed with error code
1 in c:\users\chandra\appdata\local\temp\pip-build-3qbbxo\MySQL-python\
The easiest way is to use precompiled python packages, which can be found here http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python
You need a C compiler on your system. The easiest way is to use the on Microsoft provides.
https://www.microsoft.com/en-au/download/details.aspx?id=44266
About Python :
First check is python running properly in command prompt.
If not Download and install python 2.7.
Once it is downloaded, you generally have to go to Control Panel > System > Advanced System Settings > Advanced Tab > Environment Variables > Path > Edit. Here you need to add the Windows path of your Python installation. As an example, mine is “C:\Python27”. If you don’t add this to the Path variable, you won’t be able to run Python from the command line and it’ll be annoying to test things.
Install pip :
Next, we should install pip, the Python package manager (some of this section is from experience some from this stackoverflow page). In case you were wondering, Python 3.4 already has pip installed with it! But if you don’t have it there are a few options. If you have easy_install on your machine, you can simply navigate to the Python27\Scripts directory and type:
easy_install.exe pip
This should install pip for you. If you don’t have easy_install, you can download a python script from here. Make sure to save that get-pip.py file as a .py file not .txt. You can then run the script:
python get-pip.py
Once pip is installed, you can add the directory where pip is to your path like we did before (probably something like “C:\Python27\Scripts”).
About MySQL:
pip install mysql-python
You may get the error Unable to find vcvarsall.bat either when installing pip or other packages (I got it from trying to install mysql-python package). This means Windows can’t find a C/C++ compiler (it’s looking for Visual Studio) which pip uses to install packages and install itself.
Finally test it :
You can check if mysql-python is correctly installed by going to the command prompt and typing:
C:\> python
>>>import MySQLdb
Done with alot of research, even downloaded unofficial windows binaries for python extensions - again made disappointment.
Finally, after trying simply following command and it worked.
easy_install mysql-python
Best way is to install mysqlclient in the case of getting errors in installing mysql-python. mysqlclient is a fork of it and hence it can be used as a substitute and it contains MySQLdb aswell. So, better go for it
I'm having a very hard time installing MYSQLdb under Python 3.6. I've been fighting with this for about a day now and was hoping someone had a fix. Note I am running Windows 10, MY SQL Workbench 6.3, PyCharm 2016.3.2, and Python 3.6 as already mentioned. To begin with, when trying to execute code in PyCharm which includes an import of MYSQLdb, I'd get an error saying no module found. So, I of course tried to pip install basically every binary possible. For most, I'd get the following:
C:\Users\[me]>pip install mysql-python
Collecting mysql-python
Using cached MySQL-python-1.2.5.zip
Building wheels for collected packages: mysql-python
Running setup.py bdist_wheel for mysql-python ... error
Complete output from command c:\python36\python.exe -u -c "import
setuptools, tokenize;__file__='C:\\Users\\[me]\\AppData\\Local\\Temp\\pip-build-90yksnqx\\mysql-python\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d C:\Users\[me]\AppData\Local\Temp\tmprh_xynj1pip-wheel- --python-tag cp36:
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win-amd64-3.6
copying _mysql_exceptions.py -> build\lib.win-amd64-3.6
creating build\lib.win-amd64-3.6\MySQLdb
copying MySQLdb\__init__.py -> build\lib.win-amd64-3.6\MySQLdb
copying MySQLdb\converters.py -> build\lib.win-amd64-3.6\MySQLdb
copying MySQLdb\connections.py -> build\lib.win-amd64-3.6\MySQLdb
copying MySQLdb\cursors.py -> build\lib.win-amd64-3.6\MySQLdb
copying MySQLdb\release.py -> build\lib.win-amd64-3.6\MySQLdb
copying MySQLdb\times.py -> build\lib.win-amd64-3.6\MySQLdb
creating build\lib.win-amd64-3.6\MySQLdb\constants
copying MySQLdb\constants\__init__.py -> build\lib.win-amd64-3.6\MySQLdb\constants
copying MySQLdb\constants\CR.py -> build\lib.win-amd64-3.6\MySQLdb\constants
copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win-amd64-3.6\MySQLdb\constants
copying MySQLdb\constants\ER.py -> build\lib.win-amd64-3.6\MySQLdb\constants
copying MySQLdb\constants\FLAG.py -> build\lib.win-amd64-3.6\MySQLdb\constants
copying MySQLdb\constants\REFRESH.py -> build\lib.win-amd64-3.6\MySQLdb\constants
copying MySQLdb\constants\CLIENT.py -> build\lib.win-amd64-3.6\MySQLdb\constants
running build_ext
building '_mysql' extension
creating build\temp.win-amd64-3.6
creating build\temp.win-amd64-3.6\Release
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include" -Ic:\python36\include -Ic:\python36\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /Tc_mysql.c /Fobuild\temp.win-amd64-3.6\Release\_mysql.obj /Zl
_mysql.c
_mysql.c(42): fatal error C1083: Cannot open include file: 'config-win.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2
Failed building wheel for mysql-python
Running setup.py clean for mysql-python
Failed to build mysql-python
Installing collected packages: mysql-python
Running setup.py install for mysql-python ... error
Complete output from command c:\python36\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\[me]\\AppData\\Local\\Temp\\pip-build-90yksnqx\\mysql-python\\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\[me]\AppData\Local\Temp\pip-h7ydssnj-record\install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.6
copying _mysql_exceptions.py -> build\lib.win-amd64-3.6
creating build\lib.win-amd64-3.6\MySQLdb
copying MySQLdb\__init__.py -> build\lib.win-amd64-3.6\MySQLdb
copying MySQLdb\converters.py -> build\lib.win-amd64-3.6\MySQLdb
copying MySQLdb\connections.py -> build\lib.win-amd64-3.6\MySQLdb
copying MySQLdb\cursors.py -> build\lib.win-amd64-3.6\MySQLdb
copying MySQLdb\release.py -> build\lib.win-amd64-3.6\MySQLdb
copying MySQLdb\times.py -> build\lib.win-amd64-3.6\MySQLdb
creating build\lib.win-amd64-3.6\MySQLdb\constants
copying MySQLdb\constants\__init__.py -> build\lib.win-amd64-3.6\MySQLdb\constants
copying MySQLdb\constants\CR.py -> build\lib.win-amd64-3.6\MySQLdb\constants
copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win-amd64-3.6\MySQLdb\constants
copying MySQLdb\constants\ER.py -> build\lib.win-amd64-3.6\MySQLdb\constants
copying MySQLdb\constants\FLAG.py -> build\lib.win-amd64-3.6\MySQLdb\constants
copying MySQLdb\constants\REFRESH.py -> build\lib.win-amd64-3.6\MySQLdb\constants
copying MySQLdb\constants\CLIENT.py -> build\lib.win-amd64-3.6\MySQLdb\constants
running build_ext
building '_mysql' extension
creating build\temp.win-amd64-3.6
creating build\temp.win-amd64-3.6\Release
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\BIN\x86_amd64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include" -Ic:\python36\include -Ic:\python36\include "-IC:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\8.1\include\shared" "-IC:\Program Files (x86)\Windows Kits\8.1\include\um" "-IC:\Program Files (x86)\Windows Kits\8.1\include\winrt" /Tc_mysql.c /Fobuild\temp.win-amd64-3.6\Release\_mysql.obj /Zl
_mysql.c
_mysql.c(42): fatal error C1083: Cannot open include file: 'config-win.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\x86_amd64\\cl.exe' failed with exit status 2
So, I even then tried installing the unofficial binary for 3.6 available at http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
This installed fine, but still no luck when executing in PyCharm.
Next, I went into preferences=>project interpreter in PyCharm and tried to install MYSQLdb directly from there. With that, I get this other error:
Collecting MySQLdb
Could not find a version that satisfies the requirement MySQLdb (from versions: )
No matching distribution found for MySQLdb
From my research this seems to happen a lot when using new releases of Python. Does anyone know of a workaround or when 3.6 will be supported?
try to use sqlalchemy that is fully suported for many ODBC driver. Insted of using mysqldb, mysqlconnector is better in python3.x. I migrated a project from sqlite to mysql server and work fine in python3.6
sqlalchemy offer a solution for connecting with another ODBC.
I had this same issue.
I followed the advice of another answer and got to SQLAlchemy using the pip below:
pip install SQLAlchemy
I have been unable to play with it yet, but it did install without error, so here is hoping!
I had this issue before and I found out that when using python 3.6 you just need to install mysqlclient:
1 - create a folder and than a virtualenv (virtualenv myvenv --python python3)
2 - Install the django version you want (pip install django==1.9.3)
3- Install mysqlclient (pip install mysqlclient)
If you go inside myvenv folder/lib/python3.6/site-packages you will see that MySQLdb module will be there.
I have this error from my installation of mysql-python module for django on a Windows Vista platform:
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb
I have gone through the errors 'spat' out and tried to locate the config-w.h file VC compiler is looking for but to no avail and I'm not sure what to do next (update VC compiler (v9) or remove version and stick with lower version 8 [already on system]).
Raw output:
Collecting MYSQl-python
Using cached MySQL-python-1.2.5.zip
Installing collected packages: MYSQl-python
Running setup.py install for MYSQl-python
Complete output from command C:\Python27\python.exe -c "import setuptools, tokenize;__file__='c:\\users\\i0101010\\appdata\\local\\temp\\pip-build-1vscsn\\MYSQl-python\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\i0101010\appdata\local\temp\pip-zui5a7-record\install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build\lib.win32-2.7
copying _mysql_exceptions.py -> build\lib.win32-2.7
creating build\lib.win32-2.7\MySQLdb
copying MySQLdb\__init__.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\converters.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\connections.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\cursors.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\release.py -> build\lib.win32-2.7\MySQLdb
copying MySQLdb\times.py -> build\lib.win32-2.7\MySQLdb
creating build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\__init__.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\CR.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\ER.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\FLAG.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\REFRESH.py -> build\lib.win32-2.7\MySQLdb\constants
copying MySQLdb\constants\CLIENT.py -> build\lib.win32-2.7\MySQLdb\constants
running build_ext
building '_mysql' extension
creating build\temp.win32-2.7
creating build\temp.win32-2.7\Release
C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 "-IC:\Program Files (x86)\MySQL\MySQL Connector C 6.0.2\include" -IC:\Python27\include -IC:\Python27\PC /Tc_mysql.c /Fobuild\temp.win32-2.7\Release\_mysql.obj /Zl_mysql.c
_mysql.c(42) : fatal error C1083: Cannot open include file: 'config-win.h':No such file or directory
error: command 'C:\\Program Files\\Microsoft Visual Studio 9.0\\VC\\BIN\\cl.exe' failed with exit status 2
----------------------------------------
Command "C:\Python27\python.exe -c "import setuptools, tokenize;__file__='c:\\users\\i0101010\\appdata\\local\\temp\\pip-build-1vscsn\\MYSQl-python\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\i0101010\appdata\local\temp\pip-zui5a7-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in c:\users\i0101010\appdata\local\temp\pip-build1vscsn\MYSQl-python
Screenshot:
I managed to get around the issue using easy_install instead. This solved my problem - do not rely solely on pip :)
easy_install MYSQL-python