Back

Error running LEAN (python module)

Hi,

I have tried succesfully to build and run a C# strategy. But when compiling (No errors) and running a Python Strategy QuantConnect.Lean.Launcher.exe exist with code error 1.

I think I have done all the steps indicated in github page but I miss something maybe.

My config is: VS2017 Community + Anaconda + python2.7 with panda package added (I put some capture . Any idea please??

Thanks

Update Backtest








0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


1. Install Visual Studio Community: (if you don't have it already).
1.1 Visual Studio 2017 Community edition which can be downloaded free from: https://www.visualstudio.com. Visual Studio comes with Python (if you install Python Tools for Visual Studio) but it doesn't seem to add Python to the system path. We'll need to reinstall python manually. If you already have VS installed you should be able to skip this step.

2. Install Python:
2.1 Use the Windows x86-64 MSI installer from https://www.python.org/downloads/release/python-2713/
2.2 When asked to select the features to be installed, make sure you select "Add python.exe to Path"
2.3 Once installed confirm the python27.dll is in place in C:\Windows\System32.
2.4 Add python27.dll to the system path 
2.4.1 Right mouse button on My Computer. Click Properties.
2.4.2 Click Advanced System Settings -> Environment Variables -> System Variables
2.4.3 On the "Path" section click New and enter the python27.dll path, in our example this was "C:\Windows\System32"
2.5 Install pandas and its dependencies.

3. Setup LEAN:
3.1 Download LEAN github clone, or downloading the zip. If downloading the zip - unzip to a local pathway.
3.2 Prepare Python.Runtime DLL. This is needed to run LEAN with Python.
3.2.1 Delete the existing files in \Lean\packages\QuantConnect.pythonnet.1.0.4.4\lib
3.2.2 Using windows you'll need to copy the\Lean\packages\QuantConnect.pythonnet.1.0.4.4\build\*Python.Runtime.win* file into the ..\lib\ directory with the name: Python.Runtime.dll

4 Run LEAN:
4.1 Run with a basic C# algorithm first to make sure it works (using the default credentials, just press F5).
4.1.1 You should see this exit successfully with a list of the algorithm statistics and 1 trade.
4.2 Update the config to run the python algorithm:

"algorithm-type-name": "BasicTemplateAlgorithm",
"algorithm-language": "Python",
"algorithm-location": "../../../Algorithm.Python/BasicTemplateAlgorithm.py",

4.2.1 You should see the same result of 4.1.1. 

1

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


There are steps that i follow Lucas. So it should work. I hope for you.

Test first  backtesting in console mode. after that reread my post for gui backtesting.

Maybe Alexandre can explain us a better way than fixing path in config.json (ie how to compile the missing debug version of QuantConnectView.exe).

0

We need to change the solution "Property Pages":
Right click the solution in the Solution explorer, then select Properties. 

https://ibb.co/dYYWG5

Change Release for Debug and click the Ok button.
Rebuild the solution and run.

0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Great thank you guys, I got it running

0

-no value-
0

Hi,

Another Quantopian refugee here...  I have limited experience with VS and building on Windows, so please be gentle :). I've been following the instructions in this thread and elsewhere, but am unable to get past the 'Unable to load DLL python2.7' problem (details below). Note that I did not touch the windows system PATH environment variable, because c:\windows\system32 was already listed there.  I also tried copying python27.dll from c:\windows\system32 into c:\python27, but this did not fix the problem.  Thanks.

Robert

Backtrace:

20170920 09:11:30 Trace:: JOB HANDLERS:
20170920 09:11:30 Trace::          DataFeed:     QuantConnect.Lean.Engine.DataFeeds.FileSystemDataFeed
20170920 09:11:30 Trace::          Setup:        QuantConnect.Lean.Engine.Setup.ConsoleSetupHandler
20170920 09:11:30 Trace::          RealTime:     QuantConnect.Lean.Engine.RealTime.BacktestingRealTimeHandler
20170920 09:11:30 Trace::          Results:      QuantConnect.Lean.Engine.Results.BacktestingResultHandler
20170920 09:11:30 Trace::          Transactions: QuantConnect.Lean.Engine.TransactionHandlers.BacktestingTransactionHandler
20170920 09:11:30 Trace:: Config.GetValue(): send-via-api - Using default value: False
20170920 09:11:30 ERROR:: Algorithm.Initialize() Error: Loader.TryCreatePythonAlgorithm(): Unable to import python module ../../../Algorithm.Python/BasicTemplateAlgorithm.py. Unable to load DLL 'python2.7': The specified module could not be found. (Exception from HRESULT: 0x8007007E): try re-building algorithm. Stack Trace:    at QuantConnect.Lean.Engine.Setup.ConsoleSetupHandler.CreateAlgorithmInstance(AlgorithmNodePacket algorithmNodePacket, String assemblyPath) in C:\Lean-master\Engine\Setup\ConsoleSetupHandler.cs:line 94
   at QuantConnect.Lean.Engine.Engine.Run(AlgorithmNodePacket job, AlgorithmManager manager, String assemblyPath) in C:\Lean-master\Engine\Engine.cs:line 111
    at QuantConnect.Lean.Engine.Setup.ConsoleSetupHandler.CreateAlgorithmInstance(AlgorithmNodePacket algorithmNodePacket, String assemblyPath) in C:\Lean-master\Engine\Setup\ConsoleSetupHandler.cs:line 94
   at QuantConnect.Lean.Engine.Engine.Run(AlgorithmNodePacket job, AlgorithmManager manager, String assemblyPath) in C:\Lean-master\Engine\Engine.cs:line 111

0

I had this same problem. I managed to fix it by looking at what environment my actual VS was in. I found out that even though my path was python 2.7, my VS was running Python 3.5 which was causing the problem. By setting the development environment in VS to 2.7 it fixed the problems. 

0

Thanks, Atish. Interesting, it looks like my VS Community 2017 edition doesn't include Python.  Is that others' observation?

0

Go Tools-->Python-->Python Environment.    That was where I found my issue. I also inlucded the python install when I installed VS Community 2017, so not sure what happens if you don't select that option. 

0

Okay, looks like there's possibility of adding it after the fact.  Trying now...

0

I did Tools-->Choose Toolbox Items... and was able to install Python 2.7 (64-bit), which is now listed as my default environment under Tools-->Python-->Python Environments. Unfortunately, I continue to have the same error (unable to find DLL python2.7). 

0

Click on configure environment to make sure that it is pointing to the correct files. I would do a quick google search to look into how to configure python environments in VS, because that is literally what I did to get it to work, so I only sorta knew what I was doing. 

0

Okay, thanks.

0

Noob question, what does "Prepare Python.Runtime DLL. This is needed to run LEAN with Python." means?

0

"Prepare Python.Runtime DLL. This is needed to run LEAN with Python." is the subsection.
It means you have to follow the instructions below. :-)
- Delete the existing files in \Lean\packages\QuantConnect.pythonnet.1.0.4.4\lib
- Using windows you'll need to copy the\Lean\packages\QuantConnect.pythonnet.1.0.4.4\build\*Python.Runtime.win* file into the ..\lib\ directory with the name: Python.Runtime.dll

0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


any managed to get it to work? i read and tested all the different one yet still get the same error. 

2017-11-16T07:23:15.5399263Z Error Algorithm.Initialize() Error: Loader.TryCreatePythonAlgorithm(): Unable to import python module ../../../Algorithm.Python/BasicTemplateAlgorithm.py. Unable to load DLL 'python2.7': The specified module could not be found. (Exception from HRESULT: 0x8007007E): try re-building algorithm. Stack Trace:    at QuantConnect.Lean.Engine.Setup.ConsoleSetupHandler.CreateAlgorithmInstance(AlgorithmNodePacket algorithmNodePacket, String assemblyPath) in C:\Lean-master\Engine\Setup\ConsoleSetupHandler.cs:line 94
   at QuantConnect.Lean.Engine.Engine.Run(AlgorithmNodePacket job, AlgorithmManager manager, String assemblyPath) in C:\Lean-master\Engine\Engine.cs:line 111
    at QuantConnect.Lean.Engine.Setup.ConsoleSetupHandler.CreateAlgorithmInstance(AlgorithmNodePacket algorithmNodePacket, String assemblyPath) in C:\Lean-master\Engine\Setup\ConsoleSetupHandler.cs:line 94
   at QuantConnect.Lean.Engine.Engine.Run(AlgorithmNodePacket job, AlgorithmManager manager, String assemblyPath) in C:\Lean-master\Engine\Engine.cs:line 111
 

0

Generally speaking please post LEAN / open source issues which we can't debug through QuantConnect.com to the open source group -- https://groups.google.com/forum/#!forum/lean-engine

0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Incase of error UCS4

When Run LEAN  at the first time, 
   Need to update  QuantConnect.pythonnet (Nuget package)  from 1.0.4.4 => 1.0.5.1  

Instruction

         1.  Rebuild Solution (CSharp)

         2. Tools -> Nuget package manager -> Manage Nuget package for Solution -> (Wait few minutes for checking update) -> Updates -> Check QunatConnect.pythonnet 1.0.5.1 -> Update

         3. Then try to run BasicTemplateAlgorithm.py (Python)

0

- Unable to load DLL 'python2.7': 
   Problem come from Python.Runtime.dll and Win x64

   Solution:

   Load pythonnet from the following URL and select environment DebugWin x64 or ReleaseWin x64 to build solution
   Remanrk: 

    Default environment,  DebugMono is not working for Win x64

then Copy Python.Runtime.dll   =>   C:\Lean\Lean-2.4.0.1\packages\QuantConnect.pythonnet.1.0.5.1\lib

    Testing:

       testing via run cmd C:\pythonnet-master\src\console\bin\nPython.exe, if you got python command prompt it's working.

 

     So, right now,  Ready to run Lean with Python.

 


 

 

https://github.com/QuantConnect/pythonnet/



 

0

- Unable to load DLL 'python2.7': 
   Problem come from Python.Runtime.dll and Win x64

   Solution:

     1. Load pythonnet from the following URL and rebuild with following configuration

select 

    -  "solution configuration" either  => DebugWin or ReleaseWin 
     - "solution platform"  =>  x64

then

      2. Build -> Rebuild Solution


   Remanrk: 

    Default solution configuration,  DebugMono is not working for Win x64

 

 3.CopyPython.Runtime.dll   =>   C:\Lean\Lean-2.4.0.1\packages\QuantConnect.pythonnet.1.0.5.1\lib

 Testing:

 1. run cmd C:\pythonnet-master\src\console\bin\nPython.exe, if you got python command prompt that's mean it's work good.

 

    So, right now,  Ready to run Lean with Python.

 

 

 

 

 

sorry for duplicate post. 

0

Update Backtest





0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

This discussion is closed