Login  Register

Re: QuantLib Python installation on windows machine

Posted by Luigi Ballabio on Jul 04, 2017; 1:51pm
URL: http://quantlib.414.s1.nabble.com/QuantLib-Python-installation-on-windows-machine-tp18383p18393.html

As an alternative, try executing

    pip install QuantLib-Python

and see if pip finds anything. Depending on your architecture and Python version, you might find a precompiled version.

Luigi


On Tue, Jul 4, 2017 at 3:48 PM Charles Allderman <[hidden email]> wrote:
Maybe I was not clear, unless you are compiling Python from source using VS2017 (which I know nothing about), you need to now compile QuantLib with VS2015 (MSC v.1900). Only then can you compile Quantlib-SWIG. Presumably you could point VS2017 to use the compiler, cl.exe (MSC v.1900) but I don't know how to do this.

Bottom line is that the Python executable, QuantLib and Boost all have to be compiled using the same compiler.


On Tue, Jul 4, 2017 at 2:52 PM, Vjmoodle <[hidden email]> wrote:
Charles,
Some background.
I am new for QuantLib as well as compiling complex code with Python compilers, SWIG wrappers etc.
My background is C#, JavaScript, node.js, databases, C in embedded programming and some C++ and very little Python.
I use VS 2015 a lot and python occasionally. Both were installed some time back. For my new Quant Finance analysis project I thought QuantLib will be great.
I installed Anaconda, VS 2017. I followed several different instructions on the web, mainly 
Can you please elaborate for a newbie like me about how to make sure the  python binary version is compiled by VS 2017.
Thanks.
Vijay


Sent from my iPad

On Jul 4, 2017, at 2:31 AM, Charles Allderman <[hidden email]> wrote:

Vijay

I think that as the python binary version you are using is probably compiled using MSC v.1900. (visual studio 2015). This has to be the same compiler for your QuantLib installation on windows if using visual studio.

Charles

 
---------- Forwarded message ----------
From: vj <[hidden email]>
To: [hidden email]
Cc: 
Bcc: 
Date: Mon, 3 Jul 2017 17:23:51 -0400
Subject: [Quantlib-users] QuantLib Python installation on windows machine

I am trying to install QuantLib Python in my windows machine using the instructions given in
http://quantlib.org/install/windows-python.shtml.
I did the following:

I downloaded QuantLib-1.10, SWIG and installed boost.

I built the QuantLib-1.10 in my windows 8 machine using Visual Studio 2017 comunity edition. Succefully produced QuantLib-vc141-x64-mt.lib.

Then I did the following in the command window.

cd C:\local\QuantLib-SWIG-1.9\Python
  set QL_DIR=C:\local\QuantLib-1.10
  set INCLUDE=C:\local\boost_1_64_0

and then
python setup.py build

It failed because it was looking for QuantLib-vc140-x64-mt.lib. I changed the name  QuantLib-vc141-x64-mt.lib to QuantLib-vc140-x64-mt.lib. It accepted it and built it.

Then I tried python setup.py test.

It failed giving error messages given below.

What am I doing wrong?
Can someone help me.
Thanks
Vijay

File "build\lib.win-amd64-3.6\QuantLib\QuantLib.py", line 18, in swig_import_h
elper
    return importlib.import_module(mname)
  File "C:\Users\vjkumar\Anaconda3\lib\importlib\__init__.py", line 126, in impo
rt_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 978, in _gcd_import
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load
  File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 648, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 560, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 922, in create_module
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
ImportError: DLL load failed: The specified module could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "setup.py", line 252, in <module>
    'build_ext': my_build_ext
  File "C:\Users\vjkumar\Anaconda3\lib\distutils\core.py", line 148, in setup
    dist.run_commands()
  File "C:\Users\vjkumar\Anaconda3\lib\distutils\dist.py", line 955, in run_comm
ands
    self.run_command(cmd)
  File "C:\Users\vjkumar\Anaconda3\lib\distutils\dist.py", line 974, in run_comm
and
    cmd_obj.run()
  File "setup.py", line 58, in run
    module = __import__('QuantLibTestSuite', globals(), locals(), [''])
  File "test\QuantLibTestSuite.py", line 22, in <module>
    from date import DateTest
  File "test\date.py", line 18, in <module>
    import QuantLib
  File "build\lib.win-amd64-3.6\QuantLib\__init__.py", line 21, in <module>
    from .QuantLib import *
  File "build\lib.win-amd64-3.6\QuantLib\QuantLib.py", line 21, in <module>
    _QuantLib = swig_import_helper()
  File "build\lib.win-amd64-3.6\QuantLib\QuantLib.py", line 20, in swig_import_h
elper
    return importlib.import_module('_QuantLib')
  File "C:\Users\vjkumar\Anaconda3\lib\importlib\__init__.py", line 126, in impo
rt_module
    return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_QuantLib'



---------- Forwarded message ----------
From: Andrew Leach <[hidden email]>
To: [hidden email]
Cc: 
Bcc: 
Date: Tue, 4 Jul 2017 06:14:57 +0200
Subject: [Quantlib-users] Linking Quantlib to my code problem - LNK2001 unresolved external symbol __imp___invalid_parameter
Hi,

I'm relatively new to debugging C++ code, espcially with external libraries so my appologies if this is trvial.

I'm trying to link my code to QuantLib.

The boost (1.64) and QuantLiv (1.10) on Visual Studio 2017 Community on Windows 10 went fine, no errors and built both the Debug and Release versions of QuantLib.

However, when I'm linking my program I'm getting the follwoing errors:

Severity Code Description Project File Line Suppression State
Error LNK1120 5 unresolved externals MTF_Garch d:\Users\Bob\Documents\Visual Studio 2015\Projects\MTF_Garch\Release\MTF_Garch.dll 1
Warning LNK4075 ignoring '/EDITANDCONTINUE' due to '/OPT:ICF' specification MTF_Garch d:\Users\Bob\Documents\Visual Studio 2015\Projects\MTF_Garch\MTF_Garch\QuantLib-vc141-mt-gd.lib(date.obj) 1
Error LNK2001 unresolved external symbol __imp___CrtDbgReportW MTF_Garch d:\Users\Bob\Documents\Visual Studio 2015\Projects\MTF_Garch\MTF_Garch\QuantLib-vc141-mt-gd.lib(linesearchbasedmethod.obj) 1
Error LNK2001 unresolved external symbol __imp___CrtDbgReportW MTF_Garch d:\Users\Bob\Documents\Visual Studio 2015\Projects\MTF_Garch\MTF_Garch\QuantLib-vc141-mt-gd.lib(conjugategradient.obj) 1
Error LNK2001 unresolved external symbol __imp___CrtDbgReportW MTF_Garch d:\Users\Bob\Documents\Visual Studio 2015\Projects\MTF_Garch\MTF_Garch\QuantLib-vc141-mt-gd.lib(armijo.obj) 1
Error LNK2001 unresolved external symbol __imp___CrtDbgReportW MTF_Garch d:\Users\Bob\Documents\Visual Studio 2015\Projects\MTF_Garch\MTF_Garch\QuantLib-vc141-mt-gd.lib(linesearch.obj) 1
Error LNK2001 unresolved external symbol __imp___CrtDbgReportW MTF_Garch d:\Users\Bob\Documents\Visual Studio 2015\Projects\MTF_Garch\MTF_Garch\QuantLib-vc141-mt-gd.lib(endcriteria.obj) 1
Error LNK2001 unresolved external symbol __imp___CrtDbgReportW MTF_Garch d:\Users\Bob\Documents\Visual Studio 2015\Projects\MTF_Garch\MTF_Garch\QuantLib-vc141-mt-gd.lib(constraint.obj) 1
Error LNK2001 unresolved external symbol __imp___CrtDbgReportW MTF_Garch d:\Users\Bob\Documents\Visual Studio 2015\Projects\MTF_Garch\MTF_Garch\QuantLib-vc141-mt-gd.lib(leastsquare.obj) 1
Error LNK2001 unresolved external symbol __imp___CrtDbgReportW MTF_Garch d:\Users\Bob\Documents\Visual Studio 2015\Projects\MTF_Garch\MTF_Garch\QuantLib-vc141-mt-gd.lib(simplex.obj) 1
Error LNK2001 unresolved external symbol __imp___CrtDbgReportW MTF_Garch d:\Users\Bob\Documents\Visual Studio 2015\Projects\MTF_Garch\MTF_Garch\MTF_Garch.obj 1
Error LNK2001 unresolved external symbol __imp___CrtDbgReportW MTF_Garch d:\Users\Bob\Documents\Visual Studio 2015\Projects\MTF_Garch\MTF_Garch\QuantLib-vc141-mt-gd.lib(date.obj) 1
Error LNK2001 unresolved external symbol __imp___CrtDbgReportW MTF_Garch d:\Users\Bob\Documents\Visual Studio 2015\Projects\MTF_Garch\MTF_Garch\QuantLib-vc141-mt-gd.lib(errors.obj) 1
Error LNK2001 unresolved external symbol __imp___CrtDbgReportW MTF_Garch d:\Users\Bob\Documents\Visual Studio 2015\Projects\MTF_Garch\MTF_Garch\QuantLib-vc141-mt-gd.lib(garch.obj) 1
Error LNK2001 unresolved external symbol __imp___invalid_parameter MTF_Garch d:\Users\Bob\Documents\Visual Studio 2015\Projects\MTF_Garch\MTF_Garch\QuantLib-vc141-mt-gd.lib(conjugategradient.obj) 1
Error LNK2001 unresolved external symbol __imp___invalid_parameter MTF_Garch d:\Users\Bob\Documents\Visual Studio 2015\Projects\MTF_Garch\MTF_Garch\QuantLib-vc141-mt-gd.lib(armijo.obj) 1
Error LNK2001 unresolved external symbol __imp___invalid_parameter MTF_Garch d:\Users\Bob\Documents\Visual Studio 2015\Projects\MTF_Garch\MTF_Garch\QuantLib-vc141-mt-gd.lib(linesearch.obj) 1
Error LNK2001 unresolved external symbol __imp___invalid_parameter MTF_Garch d:\Users\Bob\Documents\Visual Studio 2015\Projects\MTF_Garch\MTF_Garch\QuantLib-vc141-mt-gd.lib(constraint.obj) 1
Error LNK2001 unresolved external symbol __imp___invalid_parameter MTF_Garch d:\Users\Bob\Documents\Visual Studio 2015\Projects\MTF_Garch\MTF_Garch\QuantLib-vc141-mt-gd.lib(leastsquare.obj) 1
Error LNK2001 unresolved external symbol __imp___invalid_parameter MTF_Garch d:\Users\Bob\Documents\Visual Studio 2015\Projects\MTF_Garch\MTF_Garch\QuantLib-vc141-mt-gd.lib(simplex.obj) 1
Error LNK2001 unresolved external symbol __imp___invalid_parameter MTF_Garch d:\Users\Bob\Documents\Visual Studio 2015\Projects\MTF_Garch\MTF_Garch\QuantLib-vc141-mt-gd.lib(linesearchbasedmethod.obj) 1
Error LNK2001 unresolved external symbol __imp___invalid_parameter MTF_Garch d:\Users\Bob\Documents\Visual Studio 2015\Projects\MTF_Garch\MTF_Garch\QuantLib-vc141-mt-gd.lib(date.obj) 1
Error LNK2001 unresolved external symbol __imp___invalid_parameter MTF_Garch d:\Users\Bob\Documents\Visual Studio 2015\Projects\MTF_Garch\MTF_Garch\QuantLib-vc141-mt-gd.lib(errors.obj) 1
Error LNK2001 unresolved external symbol __imp___invalid_parameter MTF_Garch d:\Users\Bob\Documents\Visual Studio 2015\Projects\MTF_Garch\MTF_Garch\QuantLib-vc141-mt-gd.lib(garch.obj) 1
Error LNK2001 unresolved external symbol __imp___invalid_parameter MTF_Garch d:\Users\Bob\Documents\Visual Studio 2015\Projects\MTF_Garch\MTF_Garch\QuantLib-vc141-mt-gd.lib(endcriteria.obj) 1
Error LNK2001 unresolved external symbol __imp___calloc_dbg MTF_Garch d:\Users\Bob\Documents\Visual Studio 2015\Projects\MTF_Garch\MTF_Garch\QuantLib-vc141-mt-gd.lib(date.obj) 1
Error LNK2001 unresolved external symbol __imp___free_dbg MTF_Garch d:\Users\Bob\Documents\Visual Studio 2015\Projects\MTF_Garch\MTF_Garch\msvcprtd.lib(locale0_implib.obj) 1
Error LNK2001 unresolved external symbol __imp___malloc_dbg MTF_Garch d:\Users\Bob\Documents\Visual Studio 2015\Projects\MTF_Garch\MTF_Garch\msvcprtd.lib(locale0_implib.obj) 1


NB. The directory structure is the old VS105 directory structure but the project has been correctly migrated to 2017.

Everything that I do to fix this issue doesn't seem to work.

I'm including headers 

#include <ql/quantlib.hpp>
#include <ql/models/volatility/garch.hpp>

in my code.

Any suggestions on how to fix this please?

TIA.


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users