Back

Running local python algorithm error

I'm trying to run a python algorithm locally on my Mac but got the error below. I did follow the instructions for adding python support already so don't know what else am I missing. The C# version was running fine. Anyone has any idea on how to fix this? 

 

20180722 22:05:59.990 ERROR:: Loader.TryCreatePythonAlgorithm():  System.Exception: AlgorithmPythonWrapper(): The dynamic-link library for python3.6m 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.6m
  at QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper..ctor (System.String moduleName) [0x00304] in /Users/sunrise/Quant/Lean/AlgorithmFactory/Python/Wrappers/AlgorithmPythonWrapper.cs:103 
  at QuantConnect.AlgorithmFactory.Loader.TryCreatePythonAlgorithm (System.String assemblyPath, QuantConnect.Interfaces.IAlgorithm& algorithmInstance, System.String& errorMessage) [0x000b3] in /Users/sunrise/Quant/Lean/AlgorithmFactory/Loader.cs:172 
20180722 22:06:00.646 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/BasicTemplateFrameworkAlgorithm.py. AlgorithmPythonWrapper(): The dynamic-link library for python3.6m 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.6m
  at QuantConnect.Lean.Engine.Setup.ConsoleSetupHandler.CreateAlgorithmInstance (QuantConnect.Packets.AlgorithmNodePacket algorithmNodePacket, System.String assemblyPath) [0x00060] in /Users/sunrise/Quant/Lean/Engine/Setup/ConsoleSetupHandler.cs:92 
  at QuantConnect.Lean.Engine.Engine.Run (QuantConnect.Packets.AlgorithmNodePacket job, QuantConnect.Lean.Engine.AlgorithmManager manager, System.String assemblyPath) [0x000d7] in /Users/sunrise/Quant/Lean/Engine/Engine.cs:115 
 

Update Backtest







Hi Nigel N , which python distribuition do you get? Anaconda 5.2 with Python 3.6?
Please checkout whether you have libpython3.6m.dylib in your system:

find / libpython3.6* | grep libpython3.6*

Maybe you don't have the library with pymalloc (it has an 'm' after 3.6), but you should if you install Anaconda 5.2.
Another possibility is that you don't have the right environment set when launching Lean.

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.


Alexandre,



I do have python 3.6m installed. I didn't get any error messages when

running setup.py. I tried to install pythonnet manually and got the

following error below.



python3.6m -m pip install -U git+https://github.com/QuantConnect/pythonnet



Collecting git+https://github.com/QuantConnect/pythonnet



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

/private/var/folders/ks/1f29qrhn0vzgfd366fk8r39m0000gn/T/pip-req-build-8mgj84of



Building wheels for collected packages: pythonnet



Running setup.py bdist_wheel for pythonnet ... error



Complete output from command /anaconda3/bin/python3.6m -u -c "import

setuptools,

tokenize;__file__='/private/var/folders/ks/1f29qrhn0vzgfd366fk8r39m0000gn/T/pip-req-build-8mgj84of/setup.py';f=getattr(tokenize,

'open', open)(__file__);code=f.read().replace('\r\n',

'\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d

/private/var/folders/ks/1f29qrhn0vzgfd366fk8r39m0000gn/T/pip-wheel-igbqnv74
0

Could you please provide your system details (macOS version, python version)?
And the output of 

find / libpython3.6* | grep libpython3.6*

What if you try to install pythonnet simply with:

pip install -U git+https://github.com/QuantConnect/pythonnet

Lean/setup.py does it for you and it should print out an error message if it fails.

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 the same issue above.

Working on windows 10, I've installed Anaconda 5.2 with python 3.6 and I can't find any file with "python3.6m" in it.

pythonnet installed successfully, both using setup.py and using pip.

I've tried searching on anaconda's website, but can't find any reference to the "m" version...

Thanks

 

20180924 23:54:30 Error:: Algorithm.Initialize() Error: During the algorithm initialization, the following exception has  occurred: Loader.TryCreatePythonAlgorithm(): Unable to import python module ../../../Algorithm.Python/BasicTemplateFram
eworkAlgorithm.py. AlgorithmPythonWrapper(): The dynamic-link library for python3.6m could not be found. Please visit ht
tps://github.com/QuantConnect/Lean/blob/master/Algorithm.Python/readme.md for instructions on how to enable python suppo
rt in Win32NT Unable to load DLL 'python3.6m': The specified module could not be found. (Exception from HRESULT: 0x80070
07E) Stack Trace: QuantConnect.Lean.Engine.Setup.AlgorithmSetupException: During the algorithm initialization, the follo
wing exception has occurred: Loader.TryCreatePythonAlgorithm(): Unable to import python module ../../../Algorithm.Python
/BasicTemplateFrameworkAlgorithm.py. AlgorithmPythonWrapper(): The dynamic-link library for python3.6m could not be foun
d. Please visit https://github.com/QuantConnect/Lean/blob/master/Algorithm.Python/readme.md for instructions on how to e
nable python support in Win32NT Unable to load DLL 'python3.6m': The specified module could not be found. (Exception fro
m HRESULT: 0x8007007E)

0

Hi yuval sss , sorry about the incovenience. We have a pending pull request that will solve this issue.
Meanwhile, please move the the file:
Lean\packages\QuantConnect.pythonnet.1.0.5.8\build\Python.Runtime.win to
Lean\packages\QuantConnect.pythonnet.1.0.5.8\lib\Python.Runtime.dll
and rebuild the solution.

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.


Hello, Are we still facing this issue or not? Can someone please comment. Thank You!

0

I upgraded to python3.6.6 and copied the file as directed above by Alexandre, rebuilt the solution. Still getting the same error.

0

I am using Anaconda...just did a search and the python3.6m.dll (or similar) is not found anywhere. 

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)

Some forums frown on redundant posts but this forum has TONS of unanswered questions and there are several duplicates of this. I am going to post this comment on those threads, as well, to save someone else the frustration that I had.

1

Thank you for posting the result back GregasMaximus!

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.


Increadible, thank you very much GregasMaxsimus!

Indeed it was very frustrating... :)

0

You are welcome. The fact the Lean is open source is amazing and I'm happy to contribute in what little ways that I can.

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