ContinuumIO / anaconda-issues

Anaconda issue tracking
646 stars 220 forks source link

Conda-installed cython does not work (MSVC issues) #2449

Closed jennirinker closed 7 years ago

jennirinker commented 7 years ago

Steps to reproduce:

  1. Install miniconda 64-bit, Python 3.6 on Windows 7
  2. Update conda, then conda install cython
  3. Attempt to compile basic helloworld tutorial with python setup.py build_ext --inplace
  4. Command fails with infamous "error: Unable to find vcvarsall.bat"

I know this is related to the Visual Studio C compilers. My version of python was compiled using MSC v.1900 (Visual Studio 2015, a.k.a. v14), but I don't have VS 2015 installed and I don't want to install proprietary software. This page notes that VS 2015 has a "full-featured community edition", but that link now leads to VS 2017. And if you install the toolchains for MS 2017, you have vcvarsall.bat and cl.exe and all the functions that are required to run Cython, but I think msvc9compiler.py doesn't look in the correct places (probably because it's VS 2017).

Any advice on getting Cython to run on Windows with VS 2017 is appreciated.

mingwandroid commented 7 years ago

I don't want to install proprietary software. if you install the toolchains for MS 2017, you have vcvarsall.bat and cl.exe and all the functions that are required to run Cython, but I think msvc9compiler.py doesn't look in the correct places (probably because it's VS 2017).

'Free' here does not mean 'not proprietary'. A term commonly used to explain this is "free as in beer not as in free speech."

If you want to use cython avoiding as much proprietary software as possible (on Windows) you can achieve that from the Anaconda Prompt with the following:

conda install libpython m2w64-toolchain cython
echo [build] > %CONDA_PREFIX%\Lib\distutils\distutils.cfg
echo compiler = mingw32 >> %CONDA_PREFIX%\Lib\distutils\distutils.cfg

If you are just trying to avoid paying for Visual Studio 2015 then you should be able to use this link: http://landinghub.visualstudio.com/visual-cpp-build-tools

jennirinker commented 7 years ago

Touche. I know the difference between free and proprietary, and I should have been more accurate in my statement.

Also, you are a wonderful human being. After days messing around with different compiler installations, your link to the visual cpp build tools has fixed my issue with Cython. Thank you so much.

Since Cython now works for me, I'm going to close the issue.

tritemio commented 5 years ago

The link above does not work anymore. What is the current suggested link to install the free-as-in-beer MS compiler on windows 7+ to be used with current Anaconda?

ping @mingwandroid

mingwandroid commented 5 years ago

Full blown Visual Studio is free as in beer for many uses.

tritemio commented 5 years ago

It's maybe just me, but I can't find the link to Visual Studio 2015 community.

EDIT: I probably found it after creating a MS account and joining the DevEssential program (whatever that means):

screen shot 2018-08-07 at 11 37 49 am
mingwandroid commented 5 years ago

VS2017 might work ok-ish.

mingwandroid commented 5 years ago

.. for Python 3.7 and C stuff I expect it will anyway.

jennirinker commented 5 years ago

@tritemio We made a repo/documentation set with detailed instructions for setting up compilers on Windows (both f2py and cython). Got tired of re-inventing the wheel.

Documentation: https://python-at-risoe.pages.windenergy.dtu.dk/compiling-on-windows/ Repo: https://gitlab.windenergy.dtu.dk/python-at-risoe/compiling-on-windows

Sorry the repo is on GitLab -- organizational decisions above my head.

Hopefully it works for you.