简体   繁体   中英

Installing pyodbc for Python 3.7 on Windows

I am a newbie to python and I need to connect to SQL Server. I run the following command in my DB_Connect.py file. I run python DB_Connect.py from CMD line and it gives error on import pyodbc .

Pic of error

I then I ran command pip install pyodbc but it give an error saying, "Microsoft Visual C++ 14.0 is required". I installed "Microsoft Visual C++ 2015 Redistributable" to accommodate this because I would need to get a license for a full version. My understanding is that this will work. I still get this error:

Pic of pip install pyodbc err

Do I need to install a full version of Visual C++ or is there a free option? Why doesnt this CMD work with the Redistributable version? How do I get past this step?

PC: windows 7 pro - 64 Python Version: 3.7.0

Update 2018-08-15

pyodbc 4.0.24, released today, now includes Python 3.7 wheels for installing on Windows and Mac via pip .


(original answer)

pyodbc wheel files for Python 3.7 are not yet available on PyPI . They have been requested via the GitHub issue here .

You could always revert to Python 3.6 for the time being. Or, if you really need Python 3.7 right now then you'll have to install the required Visual Studio components so pip can build pyodbc from source. Details here .

I then I ran command pip install pyodbc but it give an error saying, "Microsoft Visual C++ 14.0 is required". I installed "Microsoft Visual C++ 2015 Redistributable" to accommodate this

That didn't work because you installed the runtime support for Visual C++. You need the build tools for Visual C++, described here .

This solution worked for me:

pip install --only-binary :all: pyodbc

More about above: Microsoft Visual C++ 14.0 is required (Unable to find vcvarsall.bat)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM