6

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?

Ignacio Vergara Kausel
  • 5,521
  • 4
  • 31
  • 41
p.s.w.g
  • 146,324
  • 30
  • 291
  • 331
  • You need the cpp compiler tool as it says int eh error message "error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools". Install that and see how it goes. Windows can be a pain in the ass to build python stuff. – Ignacio Vergara Kausel Jun 02 '17 at 13:33
  • @IgnacioVergaraKausel Yes, I have installed the VS C++ Build tools for 2015 and 2017. My best guess is that there's still some environment concerns that need to be worked out (perhaps I just need to add something to PATH) – p.s.w.g Jun 02 '17 at 13:34
  • I don't have real experience, but it says MS C++ 14.0. Are you sure you have that with VS C++ Build tools 2015 or 2017? Also, I've seen that sometimes having multiple compilers can "confuse" the installation process. – Ignacio Vergara Kausel Jun 02 '17 at 13:36
  • @IgnacioVergaraKausel It's entirely possible that the installation is somehow improper; I'm really not sure, and documentation is scant. I'm hoping someone can provide some references / instructions on how to get it up and running. – p.s.w.g Jun 02 '17 at 13:40

4 Answers4

11

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.

Graham
  • 7,431
  • 18
  • 59
  • 84
Laurent LAPORTE
  • 21,958
  • 6
  • 58
  • 103
  • 1
    "Since you are using Python 3.6, you need to use Microsoft Visual C++ 14.0" this implies that if I downgrade to lower version of Python, I wouldn't need to install the VS Build Tools. Is that right? – p.s.w.g Jun 02 '17 at 14:02
  • If you use Python 3.5 or Python 3.6, you need Visual c++ 14.0 to compile from source. But if you use Python 3.5, you can install a binary release directly because it is available on PyPi. – Laurent LAPORTE Jun 02 '17 at 14:08
  • Thanks for the clarification. – p.s.w.g Jun 02 '17 at 14:14
4

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.

Ignacio Vergara Kausel
  • 5,521
  • 4
  • 31
  • 41
3

I have Windows 10 with Python 3.6 on it and faced exactly similar issues. To resolve this follow:-

Step 1: Download the right version from the link: https://www.lfd.uci.edu/~gohlke/pythonlibs/#pymssql

Step 2: Executed the command:-

c:\Python27>pip install pymssql-2.2.0.dev0-cp36-cp36m-win_amd64.whl
Processing c:\python27\pymssql-2.2.0.dev0-cp36-cp36m-win_amd64.whl
Installing collected packages: pymssql
Successfully installed pymssql-2.2.0.dev0

Hope this helps...

Rupesh Kumar
  • 136
  • 2
1

Ran into the same issue, tried many things like installing MS Cpp build tools, configuring environment variables etc, finally below link helped.
I have Windows 10, Python 3.8, trying for the interpreter on PyCharm IDE

Just follow this link, its step-wise, self-explanatory and from official Microsoft site: Configure development environment for pymssql Python development

Roshan Br
  • 362
  • 2
  • 17