cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
514
Views
0
Helpful
1
Replies

import ncs failed

saccom
Level 1
Level 1

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

1 Accepted Solution

Accepted Solutions

Jan Lindblad
Cisco Employee
Cisco Employee

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

 

View solution in original post

1 Reply 1

Jan Lindblad
Cisco Employee
Cisco Employee

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