Hi,
I just began to work with Lean & QuantConnect, I'm currently exploring local development using only Lean-CLI but I get stuck when debugging with PyCharm.
I create my first project like that:
# 1. Create the workspace
mkdir MyWorkspace
cd MyWorkspace
lean init --language python
# 2. Create the project
lean project-create MyProject
# 3. Add necessary requirement for auto-complete
pip install --upgrade quantconnect-stubs
Everything seems to work as expected: the autocomplete work on both VSCode & Pycharm and I can debug on VSCode.
But I cannot debug on Pycharm, which break my heath as it is my favorite Python IDE.
The error refer to the debug configuration that seems to be broken (the one created by `lean project-create`): the debug button is disable, and when I want to edit the configuration, I see that:
Run Configuration Error: Broken configuration due to unavailable plugin or invalid configuration data.
Screenshot:
Environment:
- MacOS Sonoma 14.5 (M1 chip)
- PyCharm Community Edition 2024.1.3 (last version at this date)
Thanks for your help,
Grégoire.
Mia Alissi
Hi Grégoire,
It seems like you're having trouble with debugging in PyCharm. Here are some steps you can follow to debug Python code in PyCharm:
Make sure you are running the Professional edition of PyCharm. The local debugging for Python in PyCharm requires PyCharm's remote debugging functionality, which is only available in PyCharm Professional (source).
Follow the How to set up local autocomplete for Python in PyCharm tutorial.
Open the directory containing the main.py file in a new PyCharm window. It is important that you open the project directory itself, not your workspace (source).
Start debugging using the Debug with Lean CLI run configuration (this configuration is created when you create a new project with the CLI) (source).
Run the
lean backtest
command with the--debug pycharm
option (source).If you're still having trouble, it might be due to some issues with your Python environment or the way your project is set up. Make sure you have the correct Python version installed and that your project dependencies are correctly set up.
If the problem persists, you might want to check the QuantConnect forum for similar issues or post your question there to get help from the community (source).
Please note that the error message you're seeing in PyCharm might be due to the fact that you're using the Community Edition of PyCharm. The local debugging functionality in PyCharm is only available in the Professional Edition. If you're using the Community Edition, you might want to consider upgrading to the Professional Edition or using a different IDE that supports this functionality, such as VS Code (source).
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.
Gregoire TAJA
Thank you for your fast answer, indeed it's work with the professional edition :)
Have a good day.
Mia Alissi
I'm glad to hear that the solution worked for you, Grégoire! If you have any more questions or run into any other issues, feel free to ask. Have a great day!
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.
Gregoire TAJA
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!