QuantConnect / Lean

Lean Algorithmic Trading Engine by QuantConnect (Python, C#)
https://lean.io
Apache License 2.0
9.87k stars 3.27k forks source link

Python - Ubuntu 16.04 Error #1746

Closed learnerAI closed 6 years ago

learnerAI commented 6 years ago

Expected Behavior

Lean engine is working fine with default config.json file i.e. with CSharp. However, when I make the suggested changes i.e. // algorithm class selector //"algorithm-type-name": "BasicTemplateFrameworkAlgorithm", "algorithm-type-name": "BasicTemplateAlgorithm", // Algorithm language selector - options CSharp, FSharp, VisualBasic, Python, Java "algorithm-language": "Python",

//Physical DLL location //"algorithm-location": "QuantConnect.Algorithm.CSharp.dll", "algorithm-location": "../../../Algorithm.Python/BasicTemplateAlgorithm.py", //"algorithm-location": "QuantConnect.Algorithm.FSharp.dll", //"algorithm-location": "QuantConnect.Algorithm.VisualBasic.dll", //"algorithm-location": "QuantConnect.Algorithm.Java.dll",

I receive the following errors when running the .exe

Actual Behavior

20180322 19:51:24.602 ERROR:: Loader.TryCreatePythonAlgorithm(): System.Exception: AlgorithmPythonWrapper(): The dynamic-link library for could not be found. Please visit https://github.com/QuantConnect/Lean/blob/master/Algorithm.Python/readme.md for instructions on how to enable python support in Unix python3.6 at QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper..ctor (System.String moduleName) [0x00317] in :0 at QuantConnect.AlgorithmFactory.Loader.TryCreatePythonAlgorithm (System.String assemblyPath, QuantConnect.Interfaces.IAlgorithm& algorithmInstance, System.String& errorMessage) [0x00068] in :0 20180322 19:51:25.469 ERROR:: Engine.Run(): System.Exception: Loader.TryCreatePythonAlgorithm(): Unable to import python module ../../../Algorithm.Python/BasicTemplateAlgorithm.py. AlgorithmPythonWrapper(): The dynamic-link library for could not be found. Please visit https://github.com/QuantConnect/Lean/blob/master/Algorithm.Python/readme.md for instructions on how to enable python support in Unix python3.6: try re-building algorithm. at QuantConnect.Lean.Engine.Setup.ConsoleSetupHandler.CreateAlgorithmInstance (QuantConnect.Packets.AlgorithmNodePacket algorithmNodePacket, System.String assemblyPath) [0x0006b] in <3809d8fb051c4d86ab424c28f40f9955>:0 at QuantConnect.Lean.Engine.Engine.Run (QuantConnect.Packets.AlgorithmNodePacket job, QuantConnect.Lean.Engine.AlgorithmManager manager, System.String assemblyPath) [0x000e3] in <3809d8fb051c4d86ab424c28f40f9955>:0 20180322 19:51:25.470 Trace:: JOB HANDLERS: 20180322 19:51:25.470 Trace:: DataFeed: QuantConnect.Lean.Engine.DataFeeds.FileSystemDataFeed 20180322 19:51:25.471 Trace:: Setup: QuantConnect.Lean.Engine.Setup.ConsoleSetupHandler 20180322 19:51:25.471 Trace:: RealTime: QuantConnect.Lean.Engine.RealTime.BacktestingRealTimeHandler 20180322 19:51:25.471 Trace:: Results: QuantConnect.Lean.Engine.Results.BacktestingResultHandler 20180322 19:51:25.471 Trace:: Transactions: QuantConnect.Lean.Engine.TransactionHandlers.BacktestingTransactionHandler 20180322 19:51:25.471 Trace:: Alpha: QuantConnect.Lean.Engine.Alphas.DefaultAlphaHandler 20180322 19:51:25.475 Trace:: Config.GetValue(): send-via-api - Using default value: False 20180322 19:51:25.476 ERROR:: Algorithm.Initialize() Error: Loader.TryCreatePythonAlgorithm(): Unable to import python module ../../../Algorithm.Python/BasicTemplateAlgorithm.py. AlgorithmPythonWrapper(): The dynamic-link library for could not be found. Please visit https://github.com/QuantConnect/Lean/blob/master/Algorithm.Python/readme.md for instructions on how to enable python support in Unix python3.6: try re-building algorithm. Stack Trace: at QuantConnect.Lean.Engine.Setup.ConsoleSetupHandler.CreateAlgorithmInstance (QuantConnect.Packets.AlgorithmNodePacket algorithmNodePacket, System.String assemblyPath) [0x0006b] in <3809d8fb051c4d86ab424c28f40f9955>:0 at QuantConnect.Lean.Engine.Engine.Run (QuantConnect.Packets.AlgorithmNodePacket job, QuantConnect.Lean.Engine.AlgorithmManager manager, System.String assemblyPath) [0x000e3] in <3809d8fb051c4d86ab424c28f40f9955>:0 at QuantConnect.Lean.Engine.Setup.ConsoleSetupHandler.CreateAlgorithmInstance (QuantConnect.Packets.AlgorithmNodePacket algorithmNodePacket, System.String assemblyPath) [0x0006b] in <3809d8fb051c4d86ab424c28f40f9955>:0 at QuantConnect.Lean.Engine.Engine.Run (QuantConnect.Packets.AlgorithmNodePacket job, QuantConnect.Lean.Engine.AlgorithmManager manager, System.String assemblyPath) [0x000e3] in <3809d8fb051c4d86ab424c28f40f9955>:0

Potential Solution

Can't think of anything

Reproducing the Problem

Followed all the steps given on the main page and python link

System Information

Ubuntu 16.04

Checklist

AlexCatarino commented 6 years ago

@learnerAI What is the error?

learnerAI commented 6 years ago

QuantConnect.AlgorithmFactory.Loader.TryCreatePythonAlgorithm (System.String assemblyPath, QuantConnect.Interfaces.IAlgorithm& algorithmInstance, System.String& errorMessage) [0x00068] in :0 20180322 19:51:25.469 ERROR:: Engine.Run(): System.Exception: Loader.TryCreatePythonAlgorithm(): Unable to import python module ../../../Algorithm.Python/BasicTemplateAlgorithm.py. AlgorithmPythonWrapper(): The dynamic-link library for could not be found.

learnerAI commented 6 years ago

You can see the entire output in the question (had edited and added it under Actual behaviour) when the lean engine was run after making the changes to config.json file

ehtycuact commented 6 years ago

@AlexCatarino I don't see how this solves the issue @learnerAI mentioned. I am getting the same error.

leochirag commented 6 years ago

Can someone help, I am getting the same issue and have followed all the steps as mentioned in the readme.

ehtycuact commented 6 years ago

@leochirag Try building the python exe it worked for me. Found it in the forum: mono nPython.exe -m compileall -lq .

AlexCatarino commented 6 years ago

Hello everybody, I could run Lean successfully in Ubuntu 16.04.

Could you please give me more details on your setup? One reason for your issue is that python 3.6 is not your default python environment. What do you get when you type $ python -V

I get:

alex@ubuntu:~$ python -V
Python 3.6.5 :: Anaconda, Inc.

Also, please create a symbolic link to libpython3.6m in /usr/lib

$ sudo ln -s ~/miniconda3/lib/libpython3.6m.so /usr/lib/libpython3.6m.so