Closed jmorello12 closed 1 year ago
It looks like the python executable used in your script is definitely different from the one where the ydk is installed. Can you try the below and let me know the output?
python -c 'import sys; print(sys.executable)'
This should be the same as the output of:
which python
You can also check the installed location if there are any YDK python modules showing up.
$ which python
/usr/bin/python
Then try the below:
$ ls /usr/lib/python*/site-packages/ydk
You should see the YDK python modules here. If they are not here, try searching for them:
$ cd /usr && find . -name 'crud_service.py'
The python executables are the same:
$ python -c 'import sys; print(sys.executable)'
/usr/bin/python
$ which python
/usr/bin/python
I found ietf and openconfig models:
$ ls /usr/lib/python*/site-packages/ydk
models
$ ls /usr/lib/python2.7/site-packages/ydk/models
ietf openconfig
When looking for the crud_service.py file, it seems it's in /usr/lib64 instead.
$ cd /usr && find . -name 'crud_service.py'
./lib64/python2.7/site-packages/ydk/services/crud_service.py
Interesting.. according to (https://unix.stackexchange.com/a/74652)[this], /usr/lib64
should be linked to /usr/lib
so either path should work.. not sure why this is not done in your system.
Thanks @abhikeshav for the assistance on this.
For others facing this issue there is a hack/workaround that you need to do right now to get this working on centos. A bit of history in case TLDR happens.
This is for installing from source (https://github.com/CiscoDevNet/ydk-py#installing-from-source)
1) when installing from source, the core gets installed in the lib64 path here:
/usr/lib64/python2.7/site-packages/ydk
2) when installing from source, the *models [ietf,openconfig,cisco-]** get installed in the lib path here:
/usr/lib/python2.7/site-packages/ydk/models/
And then when you go to import anything you get missing package errors, so the hack/workaround is to use an --target= option in pip to install the models, like so :
Start from ydk-py install dir:
$ cd ietf
$ python setup.py sdist
$ sudo pip -v install --target="/usr/lib64/python2.7/site-packages" dist/ydk*.gz
$ cd ../openconfig
$ python setup sdist
$ sudo pip -v install --target="/usr/lib64/python2.7/site-packages" dist/ydk*.gz
$ cd ../cisco-ios-xr
$ python setup sdist
$ sudo pip -v install --target="/usr/lib64/python2.7/site-packages" dist/ydk*.gz
$ cd ../cisco-ios-xe
$ python setup sdist
$ sudo pip -v install --target="/usr/lib64/python2.7/site-packages" dist/ydk*.gz
Now python will import the models correctly:
In [2]: from ydk.services import CRUDService
In [3]: CRUDService.
CRUDService.create CRUDService.mro CRUDService.read_config
CRUDService.delete CRUDService.read CRUDService.update
Thanks for the note, @coldiso ! I think this should be fixed with #626. I will leave this issue open to make sure this is fixed
I still have this issue. Is this supposed to be fixed?
$ sudo cd /usr && find . -name 'crud_service.py'
...
./lib64/python2.7/site-packages/ydk/services/crud_service.py
$ ls /usr/lib/python*/site-packages/ydk
models
$ ls /usr/lib/python2.7/site-packages/ydk/models
cisco_ios_xe ietf openconfig
My issue is similar but I don't think its exactly the same - I have the same symptom in that pip install works fine but I can't seem to import any modules under ydk.
In my case, YDK gets installed in /usr/lib64/python2.7/site-packages/ydk, but all my normal python modules + the models gets installed in /usr/lib/python2.7/site-packages. I think the YDK location is wrong?
I don't want to build from source, would rather much much much prefer sticking to repos.
# uname -r
3.10.0-693.21.1.el7.x86_64
The issue still exists. Can you please try the solution in the documentation?
# Uninstall all packages
pip uninstall ydk ydk-models-openconfig ydk-models-ietf ydk-models-cisco-ios-xr ydk-models-cisco-ios-xe -y
pip install ydk
pip install --install-option="--install-purelib=/usr/lib64/python2.7/site-packages" --no-deps ydk-models-ietf
pip install --install-option="--install-purelib=/usr/lib64/python2.7/site-packages" --no-deps ydk-models-openconfig
pip install --install-option="--install-purelib=/usr/lib64/python2.7/site-packages" --no-deps ydk-models-cisco-ios-xr
pip install --install-option="--install-purelib=/usr/lib64/python2.7/site-packages" --no-deps ydk-models-cisco-ios-xe
The install put the files in the right place (usr/lib64/python2.7/site-packages), however, now I'm segfaulting and/or complaining about missing module "No module named ydk.ext.entity_utils". Something's still funky - dir gives me almost no modules?
I did install all dependencies, attach the ansible play I cooked up.
Python 2.7.5 (default, Aug 4 2017, 00:39:18)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from ydk.services import CRUDService
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib64/python2.7/site-packages/ydk/services/__init__.py", line 17, in <module>
from .codec_service import CodecService
File "/usr/lib64/python2.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 "/usr/lib64/python2.7/site-packages/ydk/entity_utils/__init__.py", line 17, in <module>
from ydk.ext.entity_utils import get_data_node_from_entity
File "/usr/lib64/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
>>> from ydk.providers import NetconfServiceProvider
Segmentation fault
>>> dir (ydk)
['__builtins__', '__doc__', '__file__', '__name__', '__package__', '__path__', 'extend_path']
# pip list | grep ydk
ydk (0.7.1)
ydk-models-cisco-ios-xe (16.8.1)
ydk-models-cisco-ios-xr (6.3.2)
ydk-models-ietf (0.1.5)
ydk-models-openconfig (0.1.5)
You are using pip version 8.1.2, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
My dependencies are as per the ansible play here: https://github.com/wintermute000/testvm-ansible/blob/master/roles/configure-yanghosts/tasks/main.yml
One minor thing: in the bash scripts provided, the yum install calls install of "devtoolset-4-gcc*". Ansible cannot handle wildcards in the yum module, but I did a yum list and installed all the packages starting with devtoolset4-gcc instead, should give the same result(?).
I am happy to raise a new tix if you think this is a separate issue?
Can you please let me know the output of the below?
cc --version
c++ --version
It should be something like the below
cc (GCC) 5.3.1 20160406 (Red Hat 5.3.1-6)
If it shows an older version, can you fix this and try the steps above again?
Thanks, fixed. Must have been something funky with the ansible shell command module, I refactored using files module (the 'proper way') and now versions report 5.x instead of 4.x.
I also discovered that one of my 'checks' was referencing a renamed openconfig model (bgp --> open_config bgp), the tutorial I had used was obviously referencing older versions.... thanks again
FEEDBACK: 1.) would STRONGLY suggest you amend the quick install instructions to make it clear that the quick install (standard pip) steps do NOT work and that the workaround is mandatory.
2.) would STRONGLY remove or clearly state 'out of date' on ubuntu install instructions if later on you state " Currently, only Centos7/RHEL7 are known to work:". This used up a TON of time.
Glad it worked. We shall update the documentation per your feedback. For clarity, the workaround only is needed for Centos OS. Quick install works on Ubuntu/macOS. Maybe this should be made clear
I followed the instructions here on a Centos machine: http://ydk.cisco.com/py/docs/getting_started.html I installed the openconfig models with "pip install ydk-models-openconfig"
When I try to run the Hello World script or any of the samples I get an error importing anything from ydk.*
Here are some details about my environment: