cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2134
Views
4
Helpful
7
Replies

ydk-py install on mac not working

jwatters06
Level 1
Level 1

Hi,

I have tried unsuccessfully to get the YDK-PY to install on an LUbuntu VM and am now trying to install on MacOS Sierra.

  • The system requirements have been installed.
  • python 2.7.13 has been installed via brew.
  • virtual env has been created
  • ydk-models-cisco-ios-xr has been installed in virualenv

(ydk) jw@bin $pip list ydk

pip (9.0.1)

pybind11 (2.1.1)

setuptools (36.2.7)

wheel (0.29.0)

ydk (0.6.0)

ydk-models-cisco-ios-xr (6.2.2)

ydk-models-ietf (0.1.3)

ydk-models-openconfig (0.1.3)

simple script run in the virtualenv appears to be working shows the version and the sys.real_prefix which i understand wouldn't have a value unless in a virtual environment

./hello-ver.py

2.7.13 (default, Jul 18 2017, 09:17:00)

[GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.42)]

/usr/local/Cellar/python/2.7.13_1/Frameworks/Python.framework/Versions/2.7

but when i try to run the hello.ydk.py example from the community it fails.

./hello-ydk.py

Traceback (most recent call last):

  File "./hello-ydk.py", line 3, in <module>

    from ydk.services import CRUDService

  File "/Users/jim.watters/Virtualenvs/ydk/lib/python2.7/site-packages/ydk/services/__init__.py", line 17, in <module>

    from .codec_service import CodecService

  File "/Users/jim.watters/Virtualenvs/ydk/lib/python2.7/site-packages/ydk/services/codec_service.py", line 25, in <module>

    from ydk.entity_utils import get_data_node_from_entity as _get_data_node_from_entity

  File "/Users/jim.watters/Virtualenvs/ydk/lib/python2.7/site-packages/ydk/entity_utils/__init__.py", line 17, in <module>

    from ydk.ext.entity_utils import get_relative_entity_path

  File "/Users/jim.watters/Virtualenvs/ydk/lib/python2.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

I have tried to search for the errors I am getting but was unable to find anything that pointed me in the right direction. If someone can point me in the right direction of what i might have missed or done wrong that would be great!

Thanks

Jim

1 Accepted Solution

Accepted Solutions

Hi abhirame, it looks like this was a red herring all along.

I tried xiaoqinz's suggestion which ended up giving me the following error:

~/git/sdapov% python test.py

Traceback (most recent call last):

  File "test.py", line 3, in <module>

    from ydk_.services import CRUDService

ImportError: dlopen(/Users/jknight/.venvs/sdapov/lib/python2.7/site-packages/ydk_.so, 2): Library not loaded: /usr/local/opt/libxml2/lib/libxml2.2.dylib

  Referenced from: /Users/jknight/.venvs/sdapov/lib/python2.7/site-packages/ydk_.so

  Reason: Incompatible library version: ydk_.so requires version 12.0.0 or later, but libxml2.2.dylib provides version 10.0.0

This lead me to realize that the YDK "Getting Started" instructions should've mentioned libxml2 as a pre-req. (I will open a pull request to get the docs fixed) I installed libxml2:

% brew install libxml2

And now xiaoqinz's code snippit works a-ok. When I revert back to my original import code... everything now imports and the script runs. So it appears that root cause was the missing libxml2 library, and had little to do with the actual python code or modules.

Also, appreciate the explanation of the C module extension. I'm not familiar with that construct at all.

Appreciate everyone's input on this.

.joel

View solution in original post

7 Replies 7

abhirame
Cisco Employee
Cisco Employee

Hi,

Can you try the workarounds in the existing issue: https://github.com/CiscoDevNet/ydk-gen/issues/513?

Thanks,

Abhi

I'm experiencing the same error as jwatters06 with this simple code snippet:

from ydk.services import CRUDService

from ydk.providers import NetconfServiceProvider

from ydk.models.cisco_ios_xe import CISCO_CDP_MIB

~/git/sdapov% python test.py

Traceback (most recent call last):

  File "test.py", line 1, in <module>

    from ydk.services import CRUDService

  File "/Users/jknight/.venvs/sdapov/lib/python2.7/site-packages/ydk/services/__init__.py", line 17, in <module>

    from .codec_service import CodecService

  File "/Users/jknight/.venvs/sdapov/lib/python2.7/site-packages/ydk/services/codec_service.py", line 25, in <module>

    from ydk.entity_utils import get_data_node_from_entity as _get_data_node_from_entity

  File "/Users/jknight/.venvs/sdapov/lib/python2.7/site-packages/ydk/entity_utils/__init__.py", line 17, in <module>

    from ydk.ext.entity_utils import get_relative_entity_path

  File "/Users/jknight/.venvs/sdapov/lib/python2.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

I'm using virtualenv and have installed ydk using pip.

~/git/sdapov% pip list | grep ydk

ydk (0.6.0)

ydk-models-cisco-ios-xr (6.2.2)

ydk-models-ietf (0.1.3)

ydk-models-openconfig (0.1.3)

Browsing the source, I see that the ydk.ext.entity_utils module is being imported by the ydk.entity_utils module (ydk-py/__init__.py at master · CiscoDevNet/ydk-py · GitHub). However, there is no ydk.ext.entity_utils module in the source tree (ydk-py/core/ydk/ext at master · CiscoDevNet/ydk-py · GitHub). How is this ever supposed to work?

.joel

Can you try the workaround mentioned in https://github.com/CiscoDevNet/ydk-gen/issues/513?

Basically, the ydk.ext module is a C extension, so you will not find python code corresponding to it. See this for more details: https://docs.python.org/2/extending/extending.html

The ydk.ext module uses exthook.py, ported from old flask project. It's been removed in latest master branch.

Hi abhirame, it looks like this was a red herring all along.

I tried xiaoqinz's suggestion which ended up giving me the following error:

~/git/sdapov% python test.py

Traceback (most recent call last):

  File "test.py", line 3, in <module>

    from ydk_.services import CRUDService

ImportError: dlopen(/Users/jknight/.venvs/sdapov/lib/python2.7/site-packages/ydk_.so, 2): Library not loaded: /usr/local/opt/libxml2/lib/libxml2.2.dylib

  Referenced from: /Users/jknight/.venvs/sdapov/lib/python2.7/site-packages/ydk_.so

  Reason: Incompatible library version: ydk_.so requires version 12.0.0 or later, but libxml2.2.dylib provides version 10.0.0

This lead me to realize that the YDK "Getting Started" instructions should've mentioned libxml2 as a pre-req. (I will open a pull request to get the docs fixed) I installed libxml2:

% brew install libxml2

And now xiaoqinz's code snippit works a-ok. When I revert back to my original import code... everything now imports and the script runs. So it appears that root cause was the missing libxml2 library, and had little to do with the actual python code or modules.

Also, appreciate the explanation of the C module extension. I'm not familiar with that construct at all.

Appreciate everyone's input on this.

.joel

Glad it worked. Thanks for your contribution to YDK!

One workaround could be:

from ydk_.services import CRUDService

from ydk_.providers import NetconfServiceProvider

from ydk.models.cisco_ios_xe import CISCO_CDP_MIB

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: