CiscoDevNet / ydk-gen

Generate model-driven APIs from YANG models
http://ciscodevnet.github.io/ydk-gen/
Apache License 2.0
137 stars 74 forks source link

ImportError: No module named ydk.ext.entity_utils #836

Closed maconrad closed 6 years ago

maconrad commented 6 years ago

Issue tracker is ONLY used for reporting bugs. Please use the YDK Community for any support issues.

Expected Behavior

hello-ydk.py script should run.

Current Behavior

Running script fails with traceback. Modules seem not be corrctly linked. But not using CentOS! Seems to be a similar issue though on Ubuntu.

Steps to Reproduce

Install according to this (for Ubuntu 18.04) http://ydk.cisco.com/py/docs/getting_started.html

Logs

Enable logging and post the logs below

Traceback (most recent call last):
  File "/home/mario/PycharmProjects/ydkTst/app.py", line 2, in <module>
    from ydk.services import CRUDService
  File "/home/mario/anaconda3/lib/python3.7/site-packages/ydk/services/__init__.py", line 17, in <module>
    from .codec_service import CodecService
  File "/home/mario/anaconda3/lib/python3.7/site-packages/ydk/services/codec_service.py", line 21, in <module>
    from ydk.entity_utils import get_data_node_from_entity as _get_data_node_from_entity
  File "/home/mario/anaconda3/lib/python3.7/site-packages/ydk/entity_utils/__init__.py", line 17, in <module>
    from ydk.ext.entity_utils import get_data_node_from_entity
  File "/home/mario/anaconda3/lib/python3.7/site-packages/ydk/exthook.py", line 87, in load_module
    raise ImportError('No module named %s' % fullname)
ImportError: No module named ydk.ext.entity_utils

System Information

for Ubuntu 18.04 using anaconda for Ubuntu 18.04 mario@zotac:~$ python Python 3.7.0 (default, Jun 28 2018, 13:15:42) [GCC 7.2.0] :: Anaconda, Inc. on linux Type "help", "copyright", "credits" or "license" for more information.

ygorelik commented 6 years ago

I have just repeated installation of YDK-0.7.3 and ran hello-ydk.py sample with single change of running XR-6.5.1 IP address. The script worked well (INFO logging enabled): YDK installation

ygorelik@ThinkStation-P500:~/ydk-0.7.3/ydk-gen$ pip list | grep ydk
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
ydk (0.7.3)
ydk-models-cisco-ios-xe (16.9.1)
ydk-models-cisco-ios-xr (6.5.1)
ydk-models-cisco-nx-os (9.2.1)
ydk-models-ietf (0.1.5.post2)
ydk-models-openconfig (0.1.6.post1)
ydk-models-ydktest (0.1.0)

Script run log

ygorelik@ThinkStation-P500:~/ydk-0.7.3/ydk-gen$ python scripts/hello-ydk.py
2018-10-31 03:28:17,452 - ydk - INFO - Path where models are to be downloaded: /home/ygorelik/.ydk/192.168.122.169_830
2018-10-31 03:28:17,542 - ydk - INFO - Connected to 192.168.122.169 on port 830 using ssh with timeout of -1
2018-10-31 03:28:17,543 - ydk - INFO - Executing CRUD read operation on [Cisco-IOS-XR-shellutil-oper:system-time]
2018-10-31 03:28:18,104 - ydk - INFO - =============Generating payload to send to device=============
2018-10-31 03:28:18,104 - ydk - INFO -
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<get xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
  <filter><system-time xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-shellutil-oper"/></filter>
</get>
</rpc>
2018-10-31 03:28:18,104 - ydk - INFO -

2018-10-31 03:28:18,417 - ydk - INFO - =============Reply payload received from device=============
2018-10-31 03:28:18,417 - ydk - INFO -
<?xml version="1.0"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="3">
  <data>
    <system-time xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-shellutil-oper">
      <clock>
        <year>2018</year>
        <month>10</month>
        <day>31</day>
        <hour>10</hour>
        <minute>28</minute>
        <second>17</second>
        <millisecond>110</millisecond>
        <wday>3</wday>
        <time-zone>UTC</time-zone>
        <time-source>calendar</time-source>
      </clock>
      <uptime>
        <host-name>gnmi</host-name>
        <uptime>1372</uptime>
      </uptime>
    </system-time>
  </data>
</rpc-reply>

2018-10-31 03:28:18,417 - ydk - INFO -

System uptime is 0:22:52
2018-10-31 03:28:18,420 - ydk - INFO - Disconnected from device

Could you please check your YDK installation and provide more information on your environment.

ydk-admin commented 6 years ago

It looks like this issue is happening because you are using ubuntu 18.04.

The libydk*.deb package we have is built on ubuntu 16.04.

Can you please try to compile libydk from source on your machine and install it:

git clone https://github.com/ciscodevnet/ydk-gen.git -b 0.7.3 cd ydk-gen pip install requirements.txt ./generate.py --libydk sudo make install -C gen-api/cpp/ydk/build install