Back

Unable to setup backtests via Python locally on Linux Debian 9 machine

Hey guys,

I was trying to setup backtests locally on my Linux Debian 9 machine. The C# program ran fine. I then followed instructions found here: Lean Python

Upon building and running Lean with Python, I get the following error message:

20200710 15:24:38.223 Trace:: PythonInitializer.Initialize(): start...
PythonEngine.Initialize(): Runtime.Initialize()...
20200710 15:24:38.378 ERROR:: Loader.TryCreatePythonAlgorithm(): System.DllNotFoundException: python3.6m assembly:<unknown assembly> type:<unknown type> member:(null)
at (wrapper managed-to-native) Python.Runtime.Runtime.Py_IsInitialized()
at Python.Runtime.Runtime.Initialize () [0x00000] in <c56ab175820d412caf052e079c2ab9ef>:0
at Python.Runtime.PythonEngine.Initialize (System.Collections.Generic.IEnumerable`1[T] args, System.Boolean setSysArgv) [0x0001e] in <c56ab175820d412caf052e079c2ab9ef>:0
at Python.Runtime.PythonEngine.Initialize (System.Boolean setSysArgv) [0x00005] in <c56ab175820d412caf052e079c2ab9ef>:0
at Python.Runtime.PythonEngine.Initialize () [0x00000] in <c56ab175820d412caf052e079c2ab9ef>:0
at QuantConnect.Python.PythonInitializer.Initialize () [0x0001a] in <15882b6f3206495eb733e234fe35e643>:0
at QuantConnect.AlgorithmFactory.Loader.TryCreatePythonAlgorithm (System.String assemblyPath, QuantConnect.Interfaces.IAlgorithm& algorithmInstance, System.String& errorMessage) [0x0005a] in <79b4e9eae48e45fdbe41e76b6c092bd8>:0
20200710 15:24:38.429 ERROR:: Engine.Run(): QuantConnect.Lean.Engine.Setup.AlgorithmSetupException: During the algorithm initialization, the following exception has occurred: Loader.TryCreatePythonAlgorithm(): Unable to import python module ../../../Algorithm.Python/BasicTemplateAlgorithm.py. python3.6m assembly:<unknown assembly> type:<unknown type> member:(null)
at QuantConnect.Lean.Engine.Setup.ConsoleSetupHandler.CreateAlgorithmInstance (QuantConnect.Packets.AlgorithmNodePacket algorithmNodePacket, System.String assemblyPath) [0x000c4] in <9994176d389648808faf1d5881237ae5>:0
at QuantConnect.Lean.Engine.Engine.Run (QuantConnect.Packets.AlgorithmNodePacket job, QuantConnect.Lean.Engine.AlgorithmManager manager, System.String assemblyPath, QuantConnect.Util.WorkerThread workerThread) [0x00101] in <9994176d389648808faf1d5881237ae5>:0
20200710 15:24:38.434 Trace:: JOB HANDLERS:
20200710 15:24:38.434 Trace:: DataFeed: QuantConnect.Lean.Engine.DataFeeds.FileSystemDataFeed
20200710 15:24:38.434 Trace:: Setup: QuantConnect.Lean.Engine.Setup.ConsoleSetupHandler
20200710 15:24:38.434 Trace:: RealTime: QuantConnect.Lean.Engine.RealTime.BacktestingRealTimeHandler
20200710 15:24:38.434 Trace:: Results: QuantConnect.Lean.Engine.Results.BacktestingResultHandler
20200710 15:24:38.434 Trace:: Transactions: QuantConnect.Lean.Engine.TransactionHandlers.BacktestingTransactionHandler
20200710 15:24:38.434 Trace:: Alpha: QuantConnect.Lean.Engine.Alphas.DefaultAlphaHandler
20200710 15:24:38.434 Trace:: ObjectStore: QuantConnect.Lean.Engine.Storage.LocalObjectStore
20200710 15:24:38.435 Trace:: DefaultAlphaHandler.Exit(): Exiting...
20200710 15:24:38.438 Trace:: DefaultAlphaHandler.Exit(): Ended
20200710 15:24:38.438 Trace:: BacktestingResultHandler.Exit(): starting...
20200710 15:24:38.441 Trace:: BacktestingResultHandler.Exit(): Saving logs...
20200710 15:24:38.444 Trace:: StopSafely(): waiting for 'Result Thread' thread to stop...
20200710 15:24:38.482 ERROR:: Algorithm.Initialize() Error: During the algorithm initialization, the following exception has occurred: Loader.TryCreatePythonAlgorithm(): Unable to import python module ../../../Algorithm.Python/BasicTemplateAlgorithm.py. python3.6m assembly:<unknown assembly> type:<unknown type> member:(null) Stack Trace: QuantConnect.Lean.Engine.Setup.AlgorithmSetupException: During the algorithm initialization, the following exception has occurred: Loader.TryCreatePythonAlgorithm(): Unable to import python module ../../../Algorithm.Python/BasicTemplateAlgorithm.py. python3.6m assembly:<unknown assembly> type:<unknown type> member:(null)
at QuantConnect.Lean.Engine.Setup.ConsoleSetupHandler.CreateAlgorithmInstance (QuantConnect.Packets.AlgorithmNodePacket algorithmNodePacket, System.String assemblyPath) [0x000c4] in <9994176d389648808faf1d5881237ae5>:0
at QuantConnect.Lean.Engine.Engine.Run (QuantConnect.Packets.AlgorithmNodePacket job, QuantConnect.Lean.Engine.AlgorithmManager manager, System.String assemblyPath, QuantConnect.Util.WorkerThread workerThread) [0x00101] in <9994176d389648808faf1d5881237ae5>:0
QuantConnect.Lean.Engine.Setup.AlgorithmSetupException: During the algorithm initialization, the following exception has occurred: Loader.TryCreatePythonAlgorithm(): Unable to import python module ../../../Algorithm.Python/BasicTemplateAlgorithm.py. python3.6m assembly:<unknown assembly> type:<unknown type> member:(null)
at QuantConnect.Lean.Engine.Setup.ConsoleSetupHandler.CreateAlgorithmInstance (QuantConnect.Packets.AlgorithmNodePacket algorithmNodePacket, System.String assemblyPath) [0x000c4] in <9994176d389648808faf1d5881237ae5>:0
at QuantConnect.Lean.Engine.Engine.Run (QuantConnect.Packets.AlgorithmNodePacket job, QuantConnect.Lean.Engine.AlgorithmManager manager, System.String assemblyPath, QuantConnect.Util.WorkerThread workerThread) [0x00101] in <9994176d389648808faf1d5881237ae5>:0

I have created a conda environment with python 3.6.8 installed, and I try to execute my Lean build inside that environment. However, when I tried to look for python3.6m (which is mentioned in the log above) using "find / libpython3.6* | grep libpython3.6*", nothing is found. I also tried to install pythonnet using pip install -U git+https://github.com/QuantConnect/pythonnet, that fails as well. 

Any help in fixing this problem shall be greatly appreciated.

Thanks,

Amulya

 

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.


Hi Kumar,

As per this discussion thread, this issue has been resolved. Mind sharing with the community how you solved it?

Best,
Derek Melchin

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.


Hi Derek,

The issue was that pythonnet was not installed at all. I ended up following pythonnet installation instructions from Pythonnet's wiki: 

https://github.com/pythonnet/pythonnet/wiki/Installation

After pythonnet was installed correctly, this error went away. 

Thanks,

Amulya

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