Page 1 of 1

Python 3.6 wrapper issue

Posted: Tue Sep 04, 2018 2:05 pm
by dreamtt007
Hi!

I tried to open the Solution twslink2pt.sln in Python 3.6 wrapper using the Visual Studio 2017, the following message is displayed. How to install the Python 3.6 wrapper? Thank you.

1>------ Build started: Project: twslink2pt, Configuration: Release Win32 ------
1>Performing Custom Build Tools
1>In order to function correctly, please ensure the following environment variables are correctly set:
1>PYTHON_INCLUDE:
1>PYTHON_LIB:
1>The system cannot find the path specified.
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(209,5): error MSB6006: "cmd.exe" exited with code 3.
1>Done building project "twslink2pt.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Re: Python 3.6 wrapper issue

Posted: Wed Sep 05, 2018 12:52 pm
by board_admin
Hello,
i downloaded the python wrapper project and opened it.
The first thing was to upgrade the project to vc141.
As platform i chosed Windows 8.1.

I got similar errors like you because my python installation changed meanwhile.

The point: You need to either adjust your python installation to match with what
is set in the project or adjust the project to match with your python installation.

In my case, python 3.6 is installed in

Code: Select all

c:\python36
(Let's assume this is the case on your machine. If not, just change the settings accordingly.)

So the include path in the c++ settings should be

Code: Select all

c:\python36\include
And in this path you should find python.h.

For the linking you need also the python36.lib. Sometimes this lib is not part of distribution.
Then you need to create it on your own from DLL.

My python 36 distribution is from:
https://www.python.org/downloads/release/python-360/

I don't remember if i built the library on my own or if it was part of distribution.
However, in the linker settings adjust path and library to

Code: Select all

c:\python36\lib\python36.lib
(For any case, i put the python36.lib into project folder / resources which is attached. But it only matches
to the python version i installed on my machine. So 3.6. I guess the library just implements the interface
which is only changing with version. Short, if you do not have the .lib in your distro, you should be able
to use the lib in attachment).

With all that, you should now be able to build the 64 bit release python36 TWSLink wrapper
using visual studio 2017. Please make sure to have the latest update of VS2017.

Re: Python 3.6 wrapper issue

Posted: Wed Sep 05, 2018 4:30 pm
by sectorbets
I would like to eventually switch to Python -- everything looks pretty straightforward, but I don't understand how to read in market data -- do you get it from IB or from some other source, and would you be able to show how you do it ??

Thank you
Rick

Re: Python 3.6 wrapper issue

Posted: Thu Sep 06, 2018 12:08 am
by dreamtt007
Hello!

Thanks a lot for the solution. I am using Window 10. My python.exe is installed with Visual Studio 2017 and located in C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64
How do I change the include path in the c++ settings? (So the include path in the c++ settings should be)
I found the python36.lib in C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\libs. How do I include the python36.lib in the linking? (For the linking you need also the python36.lib.) I tried many times to change Additional Include Directories of the Configuration properties of the twslink2pt.solution in Visual Studio 2017 but still failed. I even added the user environment variables for PYTHON_INCLUDE and PYTHON_LIB in Control Panel/System but still failed. Unfortunately, I still got the following message. The path should be there but 'The system cannot find the path specified.' Any ideas? Thank you.

1>------ Build started: Project: twslink2pt, Configuration: Debug x64 ------
1>Performing Custom Build Tools
1>In order to function correctly, please ensure the following environment variables are correctly set:
1>PYTHON_INCLUDE: C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\include
1>PYTHON_LIB: C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib
1>The system cannot find the path specified.
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(209,5): error MSB6006: "cmd.exe" exited with code 3.
1>Done building project "twslink2pt.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========So the include path in the c++ settings should be

Re: Python 3.6 wrapper issue

Posted: Thu Sep 06, 2018 12:22 pm
by board_admin
Hello,
i am sorry but you need to get familar with visual studio. I can't give support for Visual Studio here.
The project setup is based on a python 3.6 installation on

c:\python36

If your python is installed elsewhere, just change the project settings (include path and library linking) accordingly.

How to do this, please ask a visual studio forum or stack overflow.