Hi,
I am trying to create a new custom module and import it in my research notebook but am having some issues.
The module named test_mod.py looks like this:
from AlgorithmImports import *
def test_func():
return 'success'
And then in the research notebook, I do the following:
import test_mod
But I get this error:
ModuleNotFoundError Traceback (most recent call last)
Cell In [3], line 1
----> 1 import test_mod
ModuleNotFoundError: No module named 'test_mod'
I am not sure what I am missing here. Any ideas? Thanks
Nico Xenox
Hey Georgea Trading,
this should do the trick:
Note: You will have to restart the kernel every time after changing something in the python file.
Hope it helps ;)
Georgea Trading
Thanks, I tried that but it didn't work either. I think there's a combination of restarting the Kernel but probably something else.
Is there a way to reload a module using
?
Nico Xenox
Hey Georgea Trading,
isn't this what you have in mind? (backtest with test_mod and notebook attached)
Georgea Trading
Yes that's it. I was trying the same thing but somehow it wasn't working. Thanks!
Georgea Trading
I tried changing the return value and restarting the Kernel but the return value is not changed so I am not sure what I am doing wrong here.
Georgea Trading
Here:
Georgea Trading
The function is defined as:
Nico Xenox
Hey Georgea Trading,
what I meant was stopping the kernel an re-starting it. You can do this by clicking on the right side on the resources tab and click the stop symbol of your notebook.
hope it helps;)
Please consider closing this post if you’re happy with my answer
Georgea Trading
Got it thank you!
Derek Melchin
Hi Nico and Georgea Trading,
We updated the docs to explain how to restart the cloud Research Environment when importing project code.
Best,
Derek Melchin
Want to invest in QuantConnect as we build the Linux of quant finance? Checkout our Wefunder campaign to join the revolution.
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.
Georgea Trading
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!