Following instructions from: <a href="http://www.smileofthales.com/build-quantlib-for-python/" rel="nofollow">Build QuantLib for Python(SWIG)</a>
python setup.py build --compiler=msvc
I wonder why
vcvarsall.bat cannot be found. Actually, this
batch file is found at:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC
Furthermore, I've copied it to:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools
and have finally added the latter path to the
System variables -> PATH, without any improvement.
<strong><em>Ps:</em></strong> A similar topic has been raised on <a href="https://stackoverflow.com/questions/28251314/error-microsoft-visual-c-10-0-is-required-unable-to-find-vcvarsall-bat" rel="nofollow">error-microsoft-visual-c-10-0-is-required-unable-to-find-vcvarsall-bat(DUPLICATE)</a>, but none of the solutions advocated have so far helped me in overcoming this matter.
Any relevant feedback would therefore be appreciated.
<strong>OS:</strong> Windows 10
<strong>Studio:</strong> Express 2013 for Windows Desktop
<strong>IDE:</strong> PTVS v.2.2.2
Thanks in advance
<strong>1 - EDIT:</strong> See below the screenshot (incl. error)
<a href="https://i.stack.imgur.com/REuRf.png" rel="nofollow"><img alt="enter image description here" class="b-lazy" data-src="https://i.stack.imgur.com/REuRf.png" data-original="https://i.stack.imgur.com/REuRf.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" /></a>
======================================================================= C:\local\QuantLib_SWIG_1_6\Python>python setup.py build --compiler=msvc running build running build_py running build_ext building 'QuantLib._QuantLib' extension error: Unable to find vcvarsall.bat ========================================================================
<strong>2 - EDIT:</strong>
I've even gone further by updating the
get_build_version() method from the module:
msvc9compiler.py held in
#if majorVersion >= 13: updated if majorVersion > 13: # v13 was skipped and should be v14 majorVersion += 1 elif majorVersion == 13: #v13 no more skipped, UPDATED on 11/13/2016 majorVersion -= 1 # pointing specifically to v.12
Python 3.5.2 was compiled under
MSC 1900 <=> VS 2015. However it's look like the compiler cannot be found as console (
cmd) still returns
error:Unable to find vcvarsall.bat
<em>Ps</em>: Totally amazed with this installation. Solution of last resort: Install
VS2015 Community that I was postponing
<strong>3 - EDIT:</strong>
set MSSdk=1 set DISTUTILS_USE_SDK=1 python setup.py build Error: The program can't start because mspdb120.dll is missing from your computer. Try reinstalling the program to fix this problem error: command 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64\cl.exe Failed with exit status - 10737441515
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64
python setup.py build quantlib_wrap.cpp QuantLib/quantlib_wrap.cpp: fatal error C1902: Program database manager mismatch; please check your installation error: command 'C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\x86_amd64\cl.exe Failed with exit status 2Answer1:
vcvarsall.bat is needed only when running Visual C/C++ compiler from outside Visual Studio. It defines all the environment variables needed by Visual C/C++ compiler. This batch file should not be moved to other directories as installed by default as this results in setting up the environment variables wrong.
If this batch file needs to be called from another process without using full path, the directory containing
vcvarsall.bat must be defined either in <strong>user</strong> or <strong>system</strong>
PATH in Windows advanced environment settings or the directory path is added to <strong>local</strong>
PATH of the process which calls later this batch file.
Every time a process is started, Windows creates a <strong>copy</strong> of the environment variables table of current process for the new process. This means a modification of environment variable
PATH within a batch file is only active for the command process executing the batch file and all processes started by this command process after modification of <strong>local</strong>
PATH. Other processes already running on modifying
PATH within a command process continue running with their unmodified <strong>local</strong> copy of
So if <strong>user</strong> or <strong>system</strong>
PATH is modified in advanced system settings of Windows. This modification becomes active for all already running processes only after a complete restart of Windows. The modification of <strong>user</strong> or <strong>system</strong>
PATH without a restart of Windows becomes only active for processes started from Windows desktop <strong>after</strong> the modification as for those new processes the current environment variables table of Windows desktop is taken as source on creating the copy of the environment variables for the new process.
I suppose you have <strong>appended</strong> to <strong>system</strong>
PATH the string
;%ProgramFiles(x86)%\Microsoft Visual Studio 12.0\VC
whereby the semicolon at beginning is needed only if existing
PATH before modification does not already end with a semicolon.
And after this modification of <strong>system</strong>
PATH it is best to restart Windows to make it active for all processes.
By the way: I would not append this path to <strong>system</strong>
PATH as system processes don't need that directory in
PATH. I would append it to <strong>user</strong>
PATH or create <strong>user</strong>
PATH with the directory path if there is currently no
PATH in user environment table. And most often it is enough to append a specific directory path to <strong>local</strong>
PATH like here because this directory path is definitely not needed for all processes start as user process.
This is probably due to the Python
distutils package looking for another version of Visual Studio. As far as I know, Python 2.7 to 3.2 was built with VC++9; versions 3.3 and 3.4 were built with VC++10; and versions of Python from 3.5 onwards are built with VC++14. When running
distutils, each of them will look for the corresponding VC++ version unless you specify otherwise. Thus, Python (by the way, which version are you using?) doesn't find your
vcvarsall.bat from VC++12 because it doesn't look into that path.
According to <a href="https://docs.python.org/2/distutils/apiref.html#module-distutils.msvccompiler" rel="nofollow">the Python docs</a>, the workaround would be to set the environment variables
MSSdk to tell
distutils that the environment is already set up and that it doesn't need to look for
vsvarsall.bat. After that, running the script from the command prompt for Visual Studio might work.
This said, it might not be guaranteed that a module compiled with a version of VC++ will work with a Python compiled with a different one, so you might want to install and use the one corresponding to your Python installation.