cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1112
Views
0
Helpful
2
Replies

Importing NSO Python library fails

fnazari
Cisco Employee
Cisco Employee

I am trying to import the NSO Python package and it doesn't work. I sourced the required file ($ source nso-4.7/ncsrc). In Python when I try to import ncs I get this error: 

 

 

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/user/nso-4.7/src/ncs/pyapi/ncs/__init__.py", line 20, in <module>
    import _ncs
  File "/Users/user/nso-4.7/src/ncs/pyapi/_ncs/__init__.py", line 5, in <module>
    from _ncs_py2 import cdb
ImportError: No module named _ncs_py2
>>> 

 

I don't have _ncs_py2. Do I have to re-compile? 

 

 

ls src/ncs/pyapi/
total 64
-rw-r--r--   1 user  group    49B Jun 21  2018 MANIFEST.in
-rw-r--r--   1 user  group   8.3K Jun 21  2018 Makefile
-rw-r--r--@  1 user  group   1.3K Jun 21  2018 README.dist
drwxr-xr-x   5 user  group   160B Apr  8 14:23 _ncs
-rw-r--r--   1 user  group   2.4K Jun 21  2018 build.py
drwxr-xr-x   6 user  group   192B Apr  4 10:43 doc
drwxr-xr-x   3 user  group    96B Jun 21  2018 ebin
-rw-r--r--   1 user  group   6.0K Jun 21  2018 gen-constants.py
drwxr-xr-x  13 user  group   416B Jun 21  2018 include
drwxr-xr-x  21 user  group   672B Apr  8 14:23 ncs
drwxr-xr-x   8 user  group   256B Jun 21  2018 ncs_pyvm
drwxr-xr-x  15 user  group   480B Jun 21  2018 pysrc
drwxr-xr-x  11 user  group   352B Apr  4 10:45 src
2 Replies 2

Jan Lindblad
Cisco Employee
Cisco Employee

_ncs_py2 is a shared library, I don't expect you to be able to compile the sources for that easily.

Do you have it? Should be called .../src/ncs/pyapi/_ncs/_ncs_py2.so

Which python version are you using? If you're not sure, try

>>> import sys

>>> sys.version

Which host OS are you using?

What is your Python path? echo $PYTHONPATH

 

The problem was resolved by reinstalling NSO. For some reason I didn't have _ncs_py2.so for the first install. I was using Mac os and Python 2.7.15. The PATH included '/Users/user/nso-4.7/src/ncs/pyapi'. 

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the NSO Developer community: