Python 3.6 wrapper issue

Discuss, post your questions about TWSLink here.

Users who just registered, please write an email to
forum@trade-commander.de
with your username mentioned.
So we can distinguish you from bots.
Thank you
Post Reply
dreamtt007
Posts: 3
Joined: Fri Aug 31, 2018 4:24 am

Python 3.6 wrapper issue

Post by dreamtt007 » Tue Sep 04, 2018 2:05 pm

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

board_admin
Site Admin
Posts: 174
Joined: Mon Apr 24, 2017 3:24 pm

Re: Python 3.6 wrapper issue

Post by board_admin » Wed Sep 05, 2018 12:52 pm

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.
Attachments
Python3.6.zip
(164.53 KiB) Downloaded 20 times

sectorbets
Posts: 84
Joined: Wed Apr 26, 2017 12:41 pm

Re: Python 3.6 wrapper issue

Post by sectorbets » Wed Sep 05, 2018 4:30 pm

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

dreamtt007
Posts: 3
Joined: Fri Aug 31, 2018 4:24 am

Re: Python 3.6 wrapper issue

Post by dreamtt007 » Thu Sep 06, 2018 12:08 am

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

board_admin
Site Admin
Posts: 174
Joined: Mon Apr 24, 2017 3:24 pm

Re: Python 3.6 wrapper issue

Post by board_admin » Thu Sep 06, 2018 12:22 pm

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.

Post Reply