Hi, I am following all steps however when trying to create a backtest with lean locally with python, I get this error:
Python path configuration:
PYTHONHOME = (not set)
PYTHONPATH = (not set)
program name = 'python'
isolated = 0
environment = 1
user site = 1
import site = 1
sys._base_executable = 'C:\\Users\\Admin\\Desktop\\Lean-master\\Launcher\\bin\\Debug\\QuantConnect.Lean.Launcher.exe'
sys.base_prefix = 'C:\\Users\\Admin\\AppData\\Local\\conda\\conda\\envs\\lean'
sys.base_exec_prefix = 'C:\\Users\\Admin\\AppData\\Local\\conda\\conda\\envs\\lean'
sys.executable = 'C:\\Users\\Admin\\Desktop\\Lean-master\\Launcher\\bin\\Debug\\QuantConnect.Lean.Launcher.exe'
sys.prefix = 'C:\\Users\\Admin\\AppData\\Local\\conda\\conda\\envs\\lean'
sys.exec_prefix = 'C:\\Users\\Admin\\AppData\\Local\\conda\\conda\\envs\\lean'
sys.path = [
'C:\\Users\\Admin\\AppData\\Local\\conda\\conda\\envs\\lean\\python38.zip',
'.\\DLLs',
'.\\lib',
'C:\\Users\\Admin\\Desktop\\Lean-master\\Launcher\\bin\\Debug',
]
Fatal Python error: init_fs_encoding: failed to get the Python codec of the filesystem encoding
Python runtime state: core initialized
ModuleNotFoundError: No module named 'encodings'
Current thread 0x00002be4 (most recent call first):
<no Python frame>
Anyone experienced such?
Matas Urbonavicius
The solution to this error can be found here:
django - init_fs_encoding: failed to get the Python codec of the filesystem encoding - Stack Overflow
However the next error appears which looks like this:
An exception of type 'Python.Runtime.PythonException' occurred in Python.Runtime.dll but was not handled in user code
Unable to import required dependencies:
numpy:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy C-extensions failed. This error can happen for
many reasons, often due to issues with your setup or how NumPy was
installed.
We have compiled some common reasons and troubleshooting tips at:
https://numpy.org/devdocs/user/troubleshooting-importerror.html
Please note and check the following:
* The Python version is: Python3.8 from "C:\Users\Admin\Desktop\Lean-master\Launcher\bin\Debug\QuantConnect.Lean.Launcher.exe"
* The NumPy version is: "1.24.3"
and make sure that they are the versions you expect.
Please carefully study the documentation linked above for further help.
Original error was: DLL load failed while importing _multiarray_umath: The specified module could not be found.
Environmentals seem to be set correctly:
Jared Broad
Hi Matas!
I recommend using the LEAN CLI to avoid worrying about python version conflicts. It would just be a simple "pip install lean" in a command window. – https://www.lean.io/cli
Best
Jared
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.
AgedVagabond
Using cli version and just create a custom lean docker images makes things really easy. The only downside I found to using cli is that if you are using nodes and you want to upload to qc using 'lean cloud push' and download onto the node using lean cloud pull, larger projects become a problem, to overcome I split my projects into models and services and just have 2 libraries. Also a mod to the docker image to avoid using object store so I can just use my own serialisation techniques. I was running the local git version for 6 months but in that time I realised why QC made the choices they did with the cli version and realised it saves a lot of time to just build on top of that instead, you get the best of both worlds being able to easily deploy updates etc, can still use git for versioning and can use lean cloud as an intermediate to push and pull changes between machines, on top of this you can still mod anything you need too. It's worth the slight learning curve of reading some source code to save a lot of effort that has already been put in. Just in case you were wondering which path to take.
Matas Urbonavicius
Thank you Jared and AgedVagabond for the answers. I have learned that CLI is a clear winner when it comes to the ease of usage. This answer sums it up reaally well:
Getting started with running LEAN locally - Documentation? by Borishu - QuantConnect.com
In my case I am thinking of adjusting the report formatting a little (why I am considering the lean locally) - the color scheme, fonts, etc. to match the ones I always use. Is there a path for such configurations via CLI? Thanks!
Matas Urbonavicius
Oh nevermind, I just found this part of the documentation
Reports - QuantConnect.com
Lol. Thank you!
Matas Urbonavicius
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!