Back

Got an error msg when running python on desktop

 

 

 

 

 

Here is the debug msg:

2018-10-29T17:55:59.5097221Z Error Algorithm.Initialize() Error: During the algorithm initialization, the following exception has occurred: Loader.TryCreatePythonAlgorithm(): Unable to import python module ../../../Algorithm.Python/BasicTemplateFrameworkAlgorithm.py. Unable to load DLL 'python3.6m': The specified module could not be found. (Exception from HRESULT: 0x8007007E) 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/BasicTemplateFrameworkAlgorithm.py. Unable to load DLL 'python3.6m': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
   at QuantConnect.Lean.Engine.Setup.ConsoleSetupHandler.CreateAlgorithmInstance(AlgorithmNodePacket algorithmNodePacket, String assemblyPath) in C:\QC\Lean-master\Engine\Setup\ConsoleSetupHandler.cs:line 94
   at QuantConnect.Lean.Engine.Engine.Run(AlgorithmNodePacket job, AlgorithmManager manager, String assemblyPath) in C:\QC\Lean-master\Engine\Engine.cs:line 115
 QuantConnect.Lean.Engine.Setup.AlgorithmSetupException: During the algorithm initialization, the following exception has occurred: Loader.TryCreatePythonAlgorithm(): Unable to import python module ../../../Algorithm.Python/BasicTemplateFrameworkAlgorithm.py. Unable to load DLL 'python3.6m': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
   at QuantConnect.Lean.Engine.Setup.ConsoleSetupHandler.CreateAlgorithmInstance(AlgorithmNodePacket algorithmNodePacket, String assemblyPath) in C:\QC\Lean-master\Engine\Setup\ConsoleSetupHandler.cs:line 94
   at QuantConnect.Lean.Engine.Engine.Run(AlgorithmNodePacket job, AlgorithmManager manager, String assemblyPath) in C:\QC\Lean-master\Engine\Engine.cs:line 115

 

However, I do have python 3.6.5 installed on my machine:

An idea what might went wrong?

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.


Did you figure this out? Also running into a similiar issue.  I tried upgrading to python 3.6.6, re-running setup.py and rebuilding, but no help.

0

After a bunch googling, trying to understand the situation, I found that python3.6m.dll is simply the python dll, with a python-optimized malloc(). I'm still not sure how I was supposed to get the library (is it supposed to come with the python dist or do I build it?). However, I think that I have found a solution (lightly tested). I simply copied python36.dll to python3.6m.dll. Now it runs and the BasicTemplateFrameworkAlgorithm gives the same result as the C# version.

- Using a link would probably work, I did not try; I just copied

- There may be a performance penalty because you the malloc() function is not optimized for Python access patterns. But at least it works (so far)

0

Thanks, GregasMaximus.
Here is the link to the thread with your solution: Running local python algorithm error #4252.

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 

I have followed all of the steps for instaillation but still can run Quantconnect via python in my VS2017. I am on win 10 machine.

I am still getting the same error(can find python3,6m.dll). even after renaming copying and renamin python36.dll into python3.6m.dll in my Anaconda3 folder.

 

See below for error. I am trying to figure out an issue for the past 2 days but I just cant resolve it.

 

20190622 21:18:11.908 Trace:: Config.GetValue(): debug-mode - Using default value: False
20190622 21:18:11.996 Trace:: Config.Get(): Configuration key not found. Key: plugin-directory - Using default value:
20190622 21:18:11.999 Trace:: Config.Get(): Configuration key not found. Key: composer-dll-directory - Using default value: C:\Users\rasal\Source\Repos\LEAN\Launcher\bin\Debug\
20190622 21:18:14.242 Trace:: Config.Get(): Configuration key not found. Key: data-directory - Using default value: ../../../Data/
20190622 21:18:14.268 Trace:: Config.Get(): Configuration key not found. Key: version-id - Using default value:
20190622 21:18:14.269 Trace:: Config.Get(): Configuration key not found. Key: cache-location - Using default value: ../../../Data/
20190622 21:18:14.270 Trace:: Engine.Main(): LEAN ALGORITHMIC TRADING ENGINE v2.4.0.0 Mode: DEBUG (64bit)
20190622 21:18:14.270 Trace:: Engine.Main(): Started 9:18 PM
20190622 21:18:14.273 Trace:: Config.GetValue(): job-project-id - Using default value: 0
20190622 21:18:14.274 Trace:: Config.Get(): Configuration key not found. Key: algorithm-path-python - Using default value: ../../../Algorithm.Python/
20190622 21:18:14.276 Trace:: Config.GetValue(): regression-update-statistics - Using default value: False
20190622 21:18:14.277 Trace:: Config.Get(): Configuration key not found. Key: lean-manager-type - Using default value: LocalLeanManager
20190622 21:18:14.326 Trace:: Config.Get(): Configuration key not found. Key: cloud-api-url - Using default value: https://www.quantconnect.com/api/v2/
20190622 21:18:14.344 Trace:: JobQueue.NextJob(): Selected ../../../Algorithm.Python/BasicTemplateAlgorithm.py
20190622 21:18:14.663 Trace:: Config.GetValue(): ignore-version-checks - Using default value: False
20190622 21:18:14.666 Trace:: Config.GetValue(): algorithm-manager-time-loop-maximum - Using default value: 20
20190622 21:18:14.702 Trace:: Python for .NET Assembly: Python.Runtime, Version=1.0.5.20, Culture=neutral, PublicKeyToken=null
20190622 21:18:15.380 Trace:: Python for .NET Assembly: nPython, Version=1.0.5.20, Culture=neutral, PublicKeyToken=null
20190622 21:18:15.587 ERROR:: Loader.TryCreatePythonAlgorithm():  System.DllNotFoundException: Unable to load DLL 'python3.6m': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
   at Python.Runtime.Runtime.Py_IsInitialized()
   at Python.Runtime.Runtime.Initialize()
   at Python.Runtime.PythonEngine.Initialize(IEnumerable`1 args, Boolean setSysArgv)
   at Python.Runtime.PythonEngine.Initialize()
   at QuantConnect.Python.PythonInitializer.Initialize() in C:\Users\rasal\Source\Repos\LEAN\Common\Python\PythonInitializer.cs:line 36
   at QuantConnect.AlgorithmFactory.Loader.TryCreatePythonAlgorithm(String assemblyPath, IAlgorithm& algorithmInstance, String& errorMessage) in C:\Users\rasal\Source\Repos\LEAN\AlgorithmFactory\Loader.cs:line 174
20190622 21:18:15.667 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. Unable to load DLL 'python3.6m': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
   at QuantConnect.Lean.Engine.Setup.ConsoleSetupHandler.CreateAlgorithmInstance(AlgorithmNodePacket algorithmNodePacket, String assemblyPath) in C:\Users\rasal\Source\Repos\LEAN\Engine\Setup\ConsoleSetupHandler.cs:line 97
   at QuantConnect.Lean.Engine.Engine.Run(AlgorithmNodePacket job, AlgorithmManager manager, String assemblyPath) in C:\Users\rasal\Source\Repos\LEAN\Engine\Engine.cs:line 131
20190622 21:18:15.674 Trace:: JOB HANDLERS:
20190622 21:18:15.674 Trace::          DataFeed:     QuantConnect.Lean.Engine.DataFeeds.FileSystemDataFeed
20190622 21:18:15.675 Trace::          Setup:        QuantConnect.Lean.Engine.Setup.ConsoleSetupHandler
20190622 21:18:15.675 Trace::          RealTime:     QuantConnect.Lean.Engine.RealTime.BacktestingRealTimeHandler
20190622 21:18:15.676 Trace::          Results:      QuantConnect.Lean.Engine.Results.BacktestingResultHandler
20190622 21:18:15.677 Trace::          Transactions: QuantConnect.Lean.Engine.TransactionHandlers.BacktestingTransactionHandler
20190622 21:18:15.678 Trace::          Alpha:        QuantConnect.Lean.Engine.Alphas.DefaultAlphaHandler
20190622 21:18:15.700 Trace:: Waiting for threads to exit...
20190622 21:18:15.707 Trace:: Config.GetValue(): send-via-api - Using default value: False
20190622 21:18:15.717 ERROR:: Algorithm.Initialize() Error: During the algorithm initialization, the following exception has occurred: Loader.TryCreatePythonAlgorithm(): Unable to import python module ../../../Algorithm.Python/BasicTemplateAlgorithm.py. Unable to load DLL 'python3.6m': The specified module could not be found. (Exception from HRESULT: 0x8007007E) 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. Unable to load DLL 'python3.6m': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
   at QuantConnect.Lean.Engine.Setup.ConsoleSetupHandler.CreateAlgorithmInstance(AlgorithmNodePacket algorithmNodePacket, String assemblyPath) in C:\Users\rasal\Source\Repos\LEAN\Engine\Setup\ConsoleSetupHandler.cs:line 97
   at QuantConnect.Lean.Engine.Engine.Run(AlgorithmNodePacket job, AlgorithmManager manager, String assemblyPath) in C:\Users\rasal\Source\Repos\LEAN\Engine\Engine.cs:line 131
 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. Unable to load DLL 'python3.6m': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
   at QuantConnect.Lean.Engine.Setup.ConsoleSetupHandler.CreateAlgorithmInstance(AlgorithmNodePacket algorithmNodePacket, String assemblyPath) in C:\Users\rasal\Source\Repos\LEAN\Engine\Setup\ConsoleSetupHandler.cs:line 97
   at QuantConnect.Lean.Engine.Engine.Run(AlgorithmNodePacket job, AlgorithmManager manager, String assemblyPath) in C:\Users\rasal\Source\Repos\LEAN\Engine\Engine.cs:line 131
20190622 21:18:15.733 Trace:: Debug: Your log was successfully created and can be retrieved from: C:\Users\rasal\Source\Repos\LEAN\Launcher\bin\Debug\BasicTemplateAlgorithm-log.txt
20190622 21:18:15.733 Trace:: BacktestingResultHandler.Run(): Ending Thread...
20190622 21:18:15.744 Trace:: Engine.Run(): Disposing of setup handler...
20190622 21:18:15.745 Trace:: Engine.Main(): Analysis Completed and Results Posted.
Engine.Main(): Analysis Complete. Press any key to continue.

0

Hi Bor,

It’s natural to face some set-up issues, so don’t be too upset.  Some Mac users faced this error before, and they solved it by adding one more configuration to Python.Runtime.dll.config. I believe it works for Windows user too, you can find detailed instruction in section Install Python 3.6 - macOS - Note here.

Make sure you don’t use python 3.7 because Lean currently runs on python 3.6.

If you configure properly, you will see results (statistics) of the algorithm. Make sure you don’t miss any previous configuration step. Thank you for your question and looking forward to your reply!

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 Qilong ,

Thank you for your quick response, It is greatly appreciated!!!

I have tried to follow mac instruction and find my libpython3,6m.dylib in my Anaconda3 folder, but had no luck...I have tried everything on this forums and it looks like i am stuck...Any help would be greatly appreciated!!!

 

/Users/{your_user_name}/anaconda3/lib/libpython3.6m.dylib
0

Hi Bor,

Could you please check your environmental variables, and make sure Anaconda3 folder is in PATH and also PYTHONHOME?

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 Qilong,

I had to update my VS17 studio, re-did the whole installation step by step and anddd environmental variables and IT WORKED!!!! So happy!!!! Thank you for all your help!!!

One question, I can run python scripts by pressing F5, but is there a way to run them through interactive in VS17? 

Best,

Bor

0

Hi Bor,

You can find the information on this guide. Good Luck!

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.


Thank you Qilong,

The data that you send me just descibes how to run it in interactive. But in these cases it doesnt work is it because it is precompiled in C#. I nasically can import ant reference to Quantconnect? 

 

from clr import AddReference
>>> AddReference("System")
<System.Reflection.RuntimeAssembly object at 0x00000205F9E34518>
>>> AddReference("QuantConnect.Algorithm")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
System.IO.FileNotFoundException: Unable to find assembly 'QuantConnect.Algorithm'.
   at Python.Runtime.CLRModule.AddReference(String name)

0

Hi Bor,

It is totally feasible in QuantConnect, but you should import the reference in the same directory where QuantConnect.Algorithm.dll is located, that is, Lean/Launcher/bin/Debug. After you cd to that directory, there will be no bug for the same code you wrote.

Thank you!

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 Daniel,

What do you mean by cd into the directory? I am using BasicTemplateAlgorithm in VS that i can run by pressing F5, but when trying to run code through Interactive I get the following error:

>>> AddReference("QuantConnect.Algorithm")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
System.IO.FileNotFoundException: Unable to find assembly 'QuantConnect.Algorithm'.
   at Python.Runtime.CLRModule.AddReference(String name)

 

Can you please explain me what do you mean with cd into directory? I am in VS...so not sure how to do this....

Thank you for all your help and quick responses!

 

Bor

0

Hi Blackladder,

After seeing your post, I think you are correct on finding the libpython3.6m.dylib path and changing the config file. May I ask where do you install your Anaconda? It should be Anaconda 3 - 5.2.0, and should be downloaded through the link in this page. I am afraid that it is other version of python that causes this issue. Regarding the Mac version, it is possibly not the problem since some users using Mojave 10.14.2 can succeed in installation with the same instructions. 

Please follow exactly the instructions in these two pages. If this issue still exists, please feel free to let me know. Good luck!

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.


Daniel,

I have followed this instructions many time over and I am able to run it by pressing F5, I get the results in a pop-up window. But I would like to run them in Interactive window of my Visual Studio. It is much easier to track for me...Is that even a possibilty given that Quantconnect is written in C#....but I would imagine it should be, since I read you can run it in Jupyter notebooks. Am I missing something?

 

Best and thank you again for all your help!!

 

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