Hello everyone
I am trying to use Anaconda3 which comes bundled together with Visual Studio 2017 with Lean. I have therfor checked the latest version from git, installed the Python development tools together with Visual Studios Anaconda. This are the steps I have walked through:
1. Read Python introduction on github
2. Installed Python development tools using Visual Studio 2017 installer including Anaconda3 (version 5.1.0)
3. Extended PATH system variable to point to python36.dll which resides in C:\Program Files (x86)\Microsoft Visual Studio\Shared\Anaconda3_64. Please note: I havent modified/created PYTHONPATH/PYTHONHOME as it breaks my current Python development environment in Visual Studio.
4. Copied "Build/Python.Runtime.Win" to "Lib/Python.Runtime.dll"
5. Cleaned the solution and did a complete fresh rebuild of the entire solution ("Rebuild solution")
6. Modified the config.json file accordingly
7. Set Anaconda to be the system default python environment
From this point on I am able to run the python example algorithms.
However it cant find my anaconda libraries. Can someone please give me a helping hand here? What do the PYTHONPATH and PYTHONHOME need to look like in my case? This is so confusing.
Thanks a lot in advance!!!!!
20180710 15:55:58.510 ERROR:: Loader.TryCreatePythonAlgorithm(): System.Exception: AlgorithmPythonWrapper(): ModuleNotFoundError : No module named 'pandas' ModuleNotFoundError : No module named 'pandas'
bei QuantConnect.AlgorithmFactory.Python.Wrappers.AlgorithmPythonWrapper..ctor(String moduleName) in C:\Dev\Projects\Lean\AlgorithmFactory\Python\Wrappers\AlgorithmPythonWrapper.cs:Zeile 103.
bei QuantConnect.AlgorithmFactory.Loader.TryCreatePythonAlgorithm(String assemblyPath, IAlgorithm& algorithmInstance, String& errorMessage) in C:\Dev\Projects\Lean\AlgorithmFactory\Loader.cs:Zeile 172.
20180710 15:55:58.660 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. AlgorithmPythonWrapper(): ModuleNotFoundError : No module named 'pandas' ModuleNotFoundError : No module named 'pandas'
bei QuantConnect.Lean.Engine.Setup.ConsoleSetupHandler.CreateAlgorithmInstance(AlgorithmNodePacket algorithmNodePacket, String assemblyPath) in C:\Dev\Projects\Lean\Engine\Setup\ConsoleSetupHandler.cs:Zeile 92.
bei QuantConnect.Lean.Engine.Engine.Run(AlgorithmNodePacket job, AlgorithmManager manager, String assemblyPath) in C:\Dev\Projects\Lean\Engine\Engine.cs:Zeile 115.
Matthias Güntert
Whats also surprising is that Visual Studio is complaining about other modules being missing
Matthias Güntert
There are several websites, blogs and stackexchange posts that clearly vote against the use of PYTHONHOME. Shouldnt it be enough to set PATH to point to the python36.dll / python.exe / pythonw.exe?
I also noticed Visual Studio 2017 having an option called "Ignore system-wide PYTHONPATH variables". I have ensured its unchecked (as oppossed to its default)
The more I read about this python variables the more I get confused. Any Windows examples on this would be really great.
I would like to update the documentation on GitHub for this issue as soon I have solved it.
Matthias Güntert
After many hours of fiddling around with Visual Studio I found a way of using the python package that gets provided by Visual Studios 2017 to work with Lean, that I would like to share with the community. I wasnt able to get Anaconda3 working, however my main goal was getting a plotting functionality/library like seaborn and matplotlib to work with the OpenSource version anyway, so no specific need for Anaconda3 (currently).
Things I have learned:
Things still unclear to me:
Here is the step by step approach I took:
Xavier R
Hello Mathias,
Your post is really helpful.
However, I'm still not able to get Intellisense working with these modules, any idea why? I've tried re-installing python, making a custom environment, make sure Intellisense is active for all languages, still nothing.
John Addae
I have followed all instructions and steps to implement LEAN in Python wth VS but keep facing many errors when building the project file in VS, Errors screenshot attached in below link:
https://drive.google.com/file/d/17a59ULDmdRuymL4r6EIx8WvJh3_0AS7U/view?usp=sharing
Alexandre Catarino
Hi John Addae ,
We can't read the error messages in the last picture...
Assuming it's an error with .NET Framework 4.6.2, I would recommend using the Visual Studio Installer to add .NET 4.6.2 SDK (see image here) or download and install it from the Microsoft Downloader Center.
Matthias Güntert
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.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!