12-21-2023 08:30 AM
Hello,
i'm running VSCode and i would like to have an interactive window running the script in order to better learn how ncs works. Currently if i run "source ~/nso-6.1/ncsrc" before running the python script, it is ok. But i don't run the source command, the "import ncs" fails: No module named 'ncs'.
But i really would like to run in an interactive window, where i cannot put the "source" command.
How can i have an interactive window and ncs module loaded?
Thanks
Solved! Go to Solution.
01-09-2024 05:19 AM - edited 01-09-2024 05:49 AM
Hi Saccom,
The most important thing that the ncsrc script sets up is the Python module search path (PYTHONPATH). But you can do that inside the python interpreter as well. If the path to the NSO installation you intend to use is at /Users/jlindbla/nso/6.2, you could do it like this:
>>> import sys
>>> sys.path.append('/Users/jlindbla/nso/6.2/src/ncs/pyapi')
>>> import ncs
01-09-2024 05:19 AM - edited 01-09-2024 05:49 AM
Hi Saccom,
The most important thing that the ncsrc script sets up is the Python module search path (PYTHONPATH). But you can do that inside the python interpreter as well. If the path to the NSO installation you intend to use is at /Users/jlindbla/nso/6.2, you could do it like this:
>>> import sys
>>> sys.path.append('/Users/jlindbla/nso/6.2/src/ncs/pyapi')
>>> import ncs
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide