0

Following instructions from: Build QuantLib for Python(SWIG)

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.

Ps: A similar topic has been raised on error-microsoft-visual-c-10-0-is-required-unable-to-find-vcvarsall-bat(DUPLICATE), but none of the solutions advocated have so far helped me in overcoming this matter.

Any relevant feedback would therefore be appreciated.

OS: Windows 10

Studio: Express 2013 for Windows Desktop

Boost: v.1_58_0

SWIG: v.1_6

QuantLib: v.1_6

IDE: PTVS v.2.2.2

Thanks in advance

1 - EDIT: See below the screenshot (incl. error)

enter image description here

Alternatively:

=======================================================================
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
========================================================================

2 - EDIT:

I've even gone further by updating the get_build_version() method from the module: msvc9compiler.py held in

C:\Users\user\Miniconda3\Lib\distutils To:

#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

since my 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

Ps: Totally amazed with this installation. Solution of last resort: Install VS2015 Community that I was postponing

3 - EDIT:

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

Solution:

Copy mspdb120.dll To 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 2
Community
  • 1
  • 1
dark.vador
  • 619
  • 1
  • 6
  • 25
  • If you know whether you are using a 32 or 64 bit platform, look for vcvars32.bat or arm/vcvars64.bat in the VC/bin directory. vcvarsall.bat is just a front end for calling one of them. vcvarsall probably only exists in the full blown version so you're looking at something like vs2013/2015 community edition. – cup Nov 12 '16 at 09:48
  • I am using a `64-bit` windows. thanks for your suggestion, I will have a look. – dark.vador Nov 12 '16 at 09:54
  • Alternatively, run it from the cmd prompt provided by Visual Studio. That will set up all the paths for your environment. – cup Nov 12 '16 at 10:09
  • @cup: same outcome, fyi. – dark.vador Nov 12 '16 at 13:25
  • The error message `error: Unable to find vcvarsall.bat` is definitely not output by Windows command interpreter. This error message is output by the used Python script. So we need to know how `setup.py` searches for this batch file, i.e. need the block in `setup.py` around `vcvarsall.bat`. – Mofi Nov 12 '16 at 14:02
  • I agree. Interestingly, `setup.py` does not explicitly call somehow `vcvarsall.bat`. If you'd like I can only disclose the `block` around the `msvc` compiler so you'll see that none of the `class members` have been omitted there from the previous `cmd` – dark.vador Nov 12 '16 at 14:15
  • @Mofi: [SWIG-1.6.zip ---> Python\setup.py](https://sourceforge.net/projects/quantlib/files/QuantLib/1.6/other%20languages/) – dark.vador Nov 12 '16 at 14:22
  • I could see the same by looking on [setup.py](https://github.com/lballabio/QuantLib-SWIG/blob/master/Python/setup.py) on GitHub. I'm not familiar with Python, but it looks like we need to investigate the __distutils__ package. There is only Visual Studio 2008 and 2010 mentioned on [Build QuantLib for Python(SWIG)](http://www.smileofthales.com/build-quantlib-for-python/) Most likely this package is not prepared for Visual Studio 2013 or 2015 at all. – Mofi Nov 12 '16 at 14:25
  • @Mofi: Might be... Unfortunately I have not got a confirmation so far based on my searches. Reason why i was keep on installing it using `Express 2013` by acknowledging that the `vcvarsall.bat` error sounds a bit `irrational` (to me), since the `batch` is clearly found and included in `PATH` – dark.vador Nov 12 '16 at 14:35
  • 1
    @dark.vador I downloaded [SWIG-1.6.zip](https://sourceforge.net/projects/quantlib/files/QuantLib/1.6/other%20languages/) and ran multiple searches on all files for `vcvarsall`, `vars`, `vc`, `bat`, `.bat` but could not find any relevant. As my Python knowledge is very poor, I can't help further on your problem. My last advice is using free Sysinternals [Process Monitor](https://technet.microsoft.com/en-us/sysinternals/processmonitor) with an __include__ filter for __Path contains vcvarsall__ and look on the file system log after running Python command line. – Mofi Nov 12 '16 at 14:42
  • @Mofi: Only "potential" _counter-argument_ is the installation made by the following author [nstalling QuantLib and QuantLib-Python in Windows using VS Expess 2013](https://vineetv.wordpress.com/2015/07/07/installing-quantlib-python-windows/)...I will consequently work on it since it's a slightly different `cmd` approach but apparently they've managed to install it via `VS 2013`. – dark.vador Nov 12 '16 at 14:46
  • @Mofi: No worries... Please, note that I am grateful to your `free` time devoted to this post as well as the previous details provided. Best – dark.vador Nov 12 '16 at 14:48

2 Answers2

0

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 user or system PATH in Windows advanced environment settings or the directory path is added to local PATH of the process which calls later this batch file.

Every time a process is started, Windows creates a copy 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 local PATH. Other processes already running on modifying PATH within a command process continue running with their unmodified local copy of PATH.

So if user or system 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 user or system PATH without a restart of Windows becomes only active for processes started from Windows desktop after 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 appended to system 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 system PATH it is best to restart Windows to make it active for all processes.

By the way: I would not append this path to system PATH as system processes don't need that directory in PATH. I would append it to user PATH or create user 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 local PATH like here because this directory path is definitely not needed for all processes start as user process.

Mofi
  • 46,139
  • 17
  • 80
  • 143
  • Thanks for the detail explanation. Either `user` or `system` **PATH** is used, i end up with the same error (_caeteris paribus_): unable to find `vcvarsall.bat` which is seriously `weird`. – dark.vador Nov 12 '16 at 13:32
  • Thanks for the reply. I've edited the post, by inserting a screenshot (incl. error). Ps: Note that I was using `cmd` – dark.vador Nov 12 '16 at 14:00
0

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 the Python docs, the workaround would be to set the environment variables DISTUTILS_USE_SDK and 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.

Luigi Ballabio
  • 4,128
  • 21
  • 29
  • Thanks for your conclusion that matches my expectation. Regarding `distutils`, it's worth pointing that by default `msvc9compiler.py` was skipping `VC++12`, reason why I've amended it (i.e EDIT) hoping that while running the script from the command prompt `vcvarsall.bat = os.path.join(productdir, "vcvarsall.bat")` held in `C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools` would be found. I would consequently have a look at the advocated `DISTUTILS_USE_SDK` , and as a solution of last resort I would have to install `VS2015 Community`. Best – dark.vador Nov 13 '16 at 17:13
  • Your suggested workaround with `DISTUTILS_USE_SDK` and `MSSdk` is fine, however it triggers another set of `errors` on which I am working (i.e 3-EDIT). Any sharing of what's going on with `quantLib_wrapp.cpp` would thus be appreciated. Best – dark.vador Nov 13 '16 at 19:16
  • Sorry, no idea what's going on with `quantlib_wrap.cpp`. The acronym suggests that the error about a Program DataBase mismatch is related to the msPDB dll you copied, though. The compiler might be taking a harder look and deciding it's not the one it was expecting. – Luigi Ballabio Nov 13 '16 at 19:49
  • No worries, Luigi. Best, – dark.vador Nov 13 '16 at 20:35