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

ImportError: cannot import name 'CRUDService'

vadigreg
Cisco Employee
Cisco Employee

It seems the order of imports matter:

 

[root@9ca158d6bf7a ~]# python -c "from ydk.models.wireless import Cisco_IOS_XE_wireless_apf_cfg; from ydk.services import CRUDService;"
[root@9ca158d6bf7a ~]# python -c "from ydk.services import CRUDService; from ydk.models.wireless import Cisco_IOS_XE_wireless_apf_cfg;"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'ydk.services'

Reason are the traps defined by ydk.models and ydk.services. Here is the what happens:

 

 

[root@ba45adb20d36 ~]# ls -la /usr/local/lib/python3.6/site-packages/ydk
total 16
drwxr-xr-x 3 root root 4096 Jan 19 12:40 .
drwxr-xr-x 1 root root 4096 Jan 19 12:51 ..
drwxr-xr-x 3 root root 4096 Jan 19 12:40 models

[root@ba45adb20d36 ~]# cat /usr/local/lib64/python3.6/site-packages/ydk/__init__.py from pkgutil import extend_path __path__ = extend_path(__path__, __name__)

When I import ydk.models.wireless first, path /usr/local/lib/python3.6/site-packages/ydk is scanned and there's no trap for ydk.services (or ydk.* in general) so following import of ydk.service is possible by exploring the rest of the sys.path list. However when I import ydk.services (or in example ydk.providers) first trap /usr/local/lib64/python3.6/site-packages/ydk/__init__.py is for whatever reason generating the error.

Removing /usr/local/lib64/python3.6/site-packages/ydk/__init__.py resolve the issue.
Any clue of a proper way to fix this?

0 Replies 0
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 community: