Hi all;
I've got the Lean CLI installed. To do so I first uninstalled Anaconda, then installed Python, then installed Lean. You may want to suggest this as step 0 for installing Lean.
A couple of issues/questions.
First, the video shows that it installs lean-1.0.4. When I run it, it installs lean-0.1.2. How can I install the latest version?
Second, the video shows it asking for my preferred language (C# or Python). It did not prompt me. How can I set the default language?
Third, it fails when I try to login with an error of: FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\david\\.lean\\credentials'. Note: there is no folder C:\users\david\.lean. I created the folder C:\users\david\.lean and then login succeeds. You may want to have this code create the folder if needed.
Fourth, when entering the API token, it does not display it as ****. It displays the token text.
Fifth, now that it's installed, where can I find instructions on how to open/create projects, backtest them, build them, and upload them on the local CLI?
thanks - dave
Fred Painchaud
Hey David,
1- Check this out: https://www.quantconnect.com/docs/v2/lean-cli/tutorials/installation/installing-lean-cli
TL;DR: Lean CLI is a python module so pip install --upgrade lean
2- lean config set default-language python OR
lean config set default-language csharp
3- Ok thanks.
4- Ok thanks.
5- Check this out and all other pages on the left: https://www.quantconnect.com/docs/v2/lean-cli/getting-started/lean-cli
Make sure you look at the API Reference (at the end of the left).
Fred
Jasper van Merle
Please note that version 0.1.2 of the CLI is the second development version of the CLI which was released 4 days after development of the CLI started. The first publicly announced beta release came way later, and I don't think the current version of the CLI is backwards compatible with this development version. After updating the CLI to the latest version with `pip install --upgrade lean` (`lean --version` should tell you you're on version 1.0.73 or later), I highly recommend deleting C:/LeanCLI and C:/Users/David/.lean and re-doing the set up (i.e. re-creating C:/LeanCLI, running `lean init`, and running `lean login`).
Also: you're currently using Python 3.10, while the CLI only supports Python 3.6 - 3.9 at the moment. While from your screenshots it looks like version 0.1.2 of the CLI works with Python 3.10, there have been reported issues with the latest version of the CLI on Python 3.10. Therefore, until the CLI officially supports Python 3.10 I recommend you switch to a Python environment running Python 3.6, 3.7, 3.8, or 3.9.
David Thielen
I ran the update and in the output I saw: Using cached lean-1.0.72-py3-none-any.whl (310 kB)
So maybe it already installed 1.0.72 and just didn't list that at the end of what I saw. I've found that the pip output tends to hide the few useful bits of info in a ton of unnecessary output. So it might all be ok.
Thank you for the getting started link - it's exactly what I need.
lean config set default-language csharp failed:
Finally, do I care if I'm on Python 3.10 if I'm using C#? (I worry I'll honk Lean up if Python is re-installed with a different version's settings.)
thanks - dave
Fred Painchaud
Hi David,
“config” is certainly a command. Try:
lean --version
You should see version 1.0.72. If not, I don't know how you installed an old version from a fresh install but it looks like that's what happened.
If you type just “lean”, you will also have a list of commands.
Here is my “lean --version”:
'lean.json' not found
lean, version v1.0.72
The “lean.json” not found is normal here since I am using lean from a folder in which I did not do “lean init”. So it is not a “lean project folder”.
And here is the output for “lean”:
'lean.json' not found
Usage: lean [OPTIONS] COMMAND [ARGS]...
The Lean CLI by QuantConnect.
Options:
--version Show the version and exit.
--help Show this message and exit.
Commands:
backtest Backtest a project locally using Docker.
build Build Docker images of your own version of LEAN and the...
cloud Interact with the QuantConnect cloud.
config Configure Lean CLI options.
create-project Create a new project containing starter code.
data Download or generate data for local use.
gui Work with the local GUI.
init Scaffold a Lean configuration file and data directory.
library Manage custom libraries in a project.
live Start live trading a project locally using Docker.
login Log in with a QuantConnect account.
logout Log out and remove stored credentials.
logs Display the most recent backtest/live/optimization logs.
optimize Optimize a project's parameters locally using Docker.
report Generate a report of a backtest.
research Run a Jupyter Lab environment locally using Docker.
whoami Display who is logged in.
“config” is a command for sure. You must be using a version of lean CLI in which config was not a command yet.
If you do not code in Python, using python 3.10 is a bit less critical but you MAY have issues with lean CLI itself (which as you know now is a Python program). You can keep 3.10 for now and see how lean CLI reacts to commands in general. Most problems, if any, will come with packages not being there (they are not in 3.10 but are in earlier versions) or various errors during execution (from code changes in 3.10 vs earlier versions). So if you are doing stuff but get errors, keep in mind it may be because of 3.10. In theory, of course, you can also have silent errors / undefined behavior, but hopefully, these won't happen.
Fred
Fred Painchaud
Hi again David,
Just so you know, I noticed my lean CLI was not the latest so I ran “pip install --upgrade lean”, it updated lean and the quantconnect stubs to 1.0.73 and 13428, respectively. Of course, as pip always do, it also made sure all other lean dependencies are up to date (they were).
Fred
David Thielen
Ok, super weird. I ran “lean --version” and got 0.1.2. So I then ran “pip install --upgrade lean” and then version again - still 0.1.2.
And this is after installing the latest. For the first time, I never had anything else installed. So I can delete everything and install again. But it'll do the same thing.
Any ideas?
Fred Painchaud
Hi David,
Sorry but this is when one has to say “there is certainly a problem on your side during installation” while not being able to state exactly what the problem is. MAYBE installing Lean CLI from Python 3.10 creates a problem, I don't know (and don't really see why it would) but you know, we never know 😊. MAYBE you managed somehow to install a lean cli so old that you cannot update (the update from 0.1.2 to 1.0.73 is broken somehow). I don't see how you could trust your installation so yes, I would reinstall fresh, from scratch.
Install Python 3.8 (the latest 3.8.X version with a full install package). I know for sure that one works. Note you can later on install Python 3.10 on the same computer, it will only create another Python global environment. But then, you need to know what you are doing re environment variables to make your projects point to the right environment, being global or virtual. Different subject…
From Python 3.8, update your pip with “python -m pip install --upgrade pip”. I don't think this is mandatory but I always do it since I type those commands like a robot now…
Then install lean with “pip install lean”. If the latest version is not installed then - there is some major weirdness on your setup, as, I've installed lean cli probably 20 times or so, in different environments (_not_ including with Python 3.10 so far), and never ever seen an old version of lean cli being installed.
Fred
David Thielen
Fred;
That worked. I removed everything Python & Lean, and then installed Python 3.8 and then Lean. I think your guess is right, there's a problem with Python 3.10.
Anyways, one small issue left. What's lean.json?
thanks - dave
Fred Painchaud
Hey David,
lean.json is a configuration file that gets created in the current folder after you run “lean init”. “lean init” is to initialize a new project folder. Refer to the getting started documentation.
Fred
David Thielen
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!