08-26-2017 09:45 AM
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.
(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
Solved! Go to Solution.
08-29-2017 03:12 PM
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
08-26-2017 07:09 PM
Hi,
Can you try the workarounds in the existing issue: https://github.com/CiscoDevNet/ydk-gen/issues/513?
Thanks,
Abhi
08-29-2017 07:44 AM
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
08-29-2017 09:51 AM
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
08-29-2017 09:58 AM
The ydk.ext module uses exthook.py, ported from old flask project. It's been removed in latest master branch.
08-29-2017 03:12 PM
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
08-31-2017 09:25 AM
Glad it worked. Thanks for your contribution to YDK!
08-29-2017 10:08 AM
One workaround could be:
from ydk_.services import CRUDService
from ydk_.providers import NetconfServiceProvider
from ydk.models.cisco_ios_xe import CISCO_CDP_MIB
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide