Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error Installing pymssql

I'm fairly new to Python development but very quickly I've run into a roadblock and I'm not sure how to resolve it. I am using Python 3.6 and VS Code as an IDE, but I also have VS 2015 Express and VS 2017 Build Tools installed on my machine. I've set up my project in VS Code and I've been able to install a couple of dependencies through pip already, but I'm stuck trying to install pymssql.

When I run this command the terminal, I get the following error:

PS C:\path\to\project> python -m pip install pymssql -t .\
Collecting pymssql
  Using cached pymssql-2.1.3.tar.gz
Installing collected packages: pymssql
  Running setup.py install for pymssql ... error
    Complete output from command C:\...\Python\Python36-32\python.exe -u -c "import setuptools, tokenize;__file__='C:\\...\\Temp\\pip-build-sqfye0vh\\pymssql\\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:\...\pip-_407xunc-record\install-record.txt --single-version-externally-managed --compile --home=C:\...\Temp\tmpri_m4fvt:
    setup.py: platform.system() => 'Windows'
    setup.py: platform.architecture() => ('32bit', 'WindowsPE')
    running install
    running build
    running build_ext
    building '_mssql' extension
    error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools

    ----------------------------------------
Command "C:\...\Python\Python36-32\python.exe -u -c "import setuptools, tokenize;__file__='C:\\...\\Temp\\pip-build-sqfye0vh\\pymssql\\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:\...\Temp\pip-_407xunc-record\install-record.txt --single-version-externally-managed --compile --home=C:\...\Temp\tmpri_m4fvt" failed with error code 1 in C:\Users\...\Temp\pip-build-sqfye0vh\pymssql\

Since I have VS 2015 and 2017 installed, I'm not sure what else could be missing. Can anyone give me some pointers for getting around this issue?

like image 474
p.s.w.g Avatar asked Jun 02 '17 13:06

p.s.w.g


2 Answers

Note: There are official releases for Python 2.7, 3.3, 3.4, 3.5, but not 3.6.

Since you are using Python 3.6, you need to use Microsoft Visual C++ 14.0 (standalone or with Visual Studio). The best resource is the Python Wiki page: Windows Compilers.

But, If you are in a hurry, you can install a binary release. You can pick up one in the Unofficial Windows Binaries for Python Extension Packages site.

Download the wheel file from the unofficial site, and run:

pip install pymssql-2.1.3-cp36-cp36m-win_amd64.whl

Or, you can also use the HTML link:

pip install http://www.lfd.uci.edu/~gohlke/pythonlibs/vu0h7y4r/pymssql-2.1.3-cp36-cp36m-win_amd64.whl

Make sure you have a recent version of pip (currently 9.0.1) and wheel (currently 0.29.0).

Again, I recommend you to use a virtualenv.

like image 93
Laurent LAPORTE Avatar answered Sep 23 '22 09:09

Laurent LAPORTE


Looking around I found a site publishing wheels for pymssql‑2.1.3 for different versions of Python.

Check it here. Grab the one for your architecture do and give it a try by doing pip install <file>. Hopefully, it'll help you.

like image 37
Ignacio Vergara Kausel Avatar answered Sep 24 '22 09:09

Ignacio Vergara Kausel