12-04-2017 08:43 AM
Hello,
I am new to YDK and attempting to install the kit on a CentOS 7 system using the getting started guide at the link below.
http://ydk.cisco.com/py/docs/getting_started.html
The Quick Start installation is successful but running sample code generates an error - ImportError: No module named 'ydk.types'.
Troubleshooting help would be greatly appreciated!
Thanks,
Eric
[root@mars ehouby]# pip install ydk-models-cisco-ios-xe ydk-models-cisco-ios-xr
Collecting ydk-models-cisco-ios-xe
Using cached ydk_models_cisco_ios_xe-16.6.1.post1-py2.py3-none-any.whl
Collecting ydk-models-cisco-ios-xr
Using cached ydk_models_cisco_ios_xr-6.3.1-py2.py3-none-any.whl
Collecting ydk>=0.6.1 (from ydk-models-cisco-ios-xe)
Using cached ydk-0.6.2.tar.gz
Collecting ydk-models-ietf>=0.1.3 (from ydk-models-cisco-ios-xe)
Using cached ydk_models_ietf-0.1.4-py2.py3-none-any.whl
Collecting ydk-models-openconfig>=0.1.3 (from ydk-models-cisco-ios-xe)
Using cached ydk_models_openconfig-0.1.4-py2.py3-none-any.whl
Requirement already satisfied: pybind11>=2.1.1 in /usr/lib/python3.4/site-packages (from ydk>=0.6.1->ydk-models-cisco-ios-xe)
Installing collected packages: ydk, ydk-models-ietf, ydk-models-openconfig, ydk-models-cisco-ios-xe, ydk-models-cisco-ios-xr
Running setup.py install for ydk ... done
Successfully installed ydk-0.6.2 ydk-models-cisco-ios-xe-16.6.1.post1 ydk-models-cisco-ios-xr-6.3.1 ydk-models-ietf-0.1.4 ydk-models-openconfig-0.1.4
[root@mars ehouby]# pip list
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.
asn1crypto (0.22.0)
bcrypt (3.1.3)
certifi (2017.11.5)
cffi (1.10.0)
chardet (3.0.4)
cryptography (2.0)
idna (2.6)
lxml (3.8.0)
ncclient (0.5.3)
paramiko (2.2.1)
pip (9.0.1)
pyang (1.6)
pyasn1 (0.3.3)
pybind11 (2.2.1)
pycparser (2.18)
PyNaCl (1.1.2)
requests (2.18.4)
setuptools (19.2)
six (1.10.0)
urllib3 (1.22)
ydk (0.6.2)
ydk-models-cisco-ios-xe (16.6.1.post1)
ydk-models-cisco-ios-xr (6.3.1)
ydk-models-ietf (0.1.4)
ydk-models-openconfig (0.1.4)
[ehouby@mars ehouby]# cd DevNet-Code-Samples/ydk-py/core/samples/
[ehouby@mars samples]$ python bgp.py -h
Traceback (most recent call last):
File "bgp.py", line 29, in <module>
from ydk.types import Empty
ImportError: No module named 'ydk.types'
[ehouby@mars samples]$
Solved! Go to Solution.
12-04-2017 10:01 AM
Hi Eric,
Sorry you are facing this. This is likely because of this known issue (https://github.com/CiscoDevNet/ydk-gen/issues/524). Can you please try the below?
first uninstall all ydk packages
sudo pip uninstall ydk -y
sudo pip uninstall ydk-models-ietf -y
sudo pip uninstall ydk-models-openconfig -y
sudo pip uninstall ydk-models-cisco-ios-xr -y
sudo pip uninstall ydk-models-cisco-ios-xe -y
install ydk core
sudo pip install ydk
install model APIs
sudo pip install install-option="install-purelib=/usr/lib64/python2.7/site-packages" --no-deps ydk-models-ietf
sudo pip install install-option="install-purelib=/usr/lib64/python2.7/site-packages" --no-deps ydk-models-openconfig
sudo pip install install-option="install-purelib=/usr/lib64/python2.7/site-packages" --no-deps ydk-models-cisco-ios-xr
sudo pip install install-option="install-purelib=/usr/lib64/python2.7/site-packages" --no-deps ydk-models-cisco-ios-xe
12-04-2017 10:01 AM
Hi Eric,
Sorry you are facing this. This is likely because of this known issue (https://github.com/CiscoDevNet/ydk-gen/issues/524). Can you please try the below?
first uninstall all ydk packages
sudo pip uninstall ydk -y
sudo pip uninstall ydk-models-ietf -y
sudo pip uninstall ydk-models-openconfig -y
sudo pip uninstall ydk-models-cisco-ios-xr -y
sudo pip uninstall ydk-models-cisco-ios-xe -y
install ydk core
sudo pip install ydk
install model APIs
sudo pip install install-option="install-purelib=/usr/lib64/python2.7/site-packages" --no-deps ydk-models-ietf
sudo pip install install-option="install-purelib=/usr/lib64/python2.7/site-packages" --no-deps ydk-models-openconfig
sudo pip install install-option="install-purelib=/usr/lib64/python2.7/site-packages" --no-deps ydk-models-cisco-ios-xr
sudo pip install install-option="install-purelib=/usr/lib64/python2.7/site-packages" --no-deps ydk-models-cisco-ios-xe
12-04-2017 11:36 AM
I uninstalled ydk and reinstalled per your process above but i am still seeing an error. Installation of the models says it was successful but they do not show up in pip list.
Thanks,
Eric
[ehouby@mars samples]$ sudo pip list
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.
asn1crypto (0.22.0)
bcrypt (3.1.3)
certifi (2017.11.5)
cffi (1.10.0)
chardet (3.0.4)
cryptography (2.0)
idna (2.6)
lxml (3.8.0)
ncclient (0.5.3)
paramiko (2.2.1)
pip (9.0.1)
pyang (1.6)
pyasn1 (0.3.3)
pybind11 (2.2.1)
pycparser (2.18)
PyNaCl (1.1.2)
requests (2.18.4)
setuptools (19.2)
six (1.10.0)
urllib3 (1.22)
[ehouby@mars samples]$
[ehouby@mars samples]$ sudo pip install ydk
Collecting ydk
Using cached ydk-0.6.2.tar.gz
Requirement already satisfied: pybind11>=2.1.1 in /usr/lib/python3.4/site-packages (from ydk)
Installing collected packages: ydk
Running setup.py install for ydk ... done
Successfully installed ydk-0.6.2
[ehouby@mars samples]$ sudo pip install --install-option="--install-purelib=/usr/lib64/python2.7/site-packages" --no-deps ydk-models-ietf
/usr/lib/python3.4/site-packages/pip/commands/install.py:194: UserWarning: Disabling all use of wheels due to the use of --build-options / --global-options / --install-options.
cmdoptions.check_install_build_global(options)
Collecting ydk-models-ietf
Using cached ydk-models-ietf-0.1.4.tar.gz
Installing collected packages: ydk-models-ietf
Running setup.py install for ydk-models-ietf ... done
Successfully installed ydk-models-ietf
[ehouby@mars samples]$ sudo pip install --install-option="--install-purelib=/usr/lib64/python2.7/site-packages" --no-deps ydk-models-openconfig
/usr/lib/python3.4/site-packages/pip/commands/install.py:194: UserWarning: Disabling all use of wheels due to the use of --build-options / --global-options / --install-options.
cmdoptions.check_install_build_global(options)
Collecting ydk-models-openconfig
Using cached ydk-models-openconfig-0.1.4.tar.gz
Installing collected packages: ydk-models-openconfig
Running setup.py install for ydk-models-openconfig ... done
Successfully installed ydk-models-openconfig
[ehouby@mars samples]$ sudo pip install --install-option="--install-purelib=/usr/lib64/python2.7/site-packages" --no-deps ydk-models-cisco-ios-xr
/usr/lib/python3.4/site-packages/pip/commands/install.py:194: UserWarning: Disabling all use of wheels due to the use of --build-options / --global-options / --install-options.
cmdoptions.check_install_build_global(options)
Collecting ydk-models-cisco-ios-xr
Using cached ydk-models-cisco-ios-xr-6.3.1.tar.gz
Installing collected packages: ydk-models-cisco-ios-xr
Running setup.py install for ydk-models-cisco-ios-xr ... done
Successfully installed ydk-models-cisco-ios-xr
[ehouby@mars samples]$ sudo pip install --install-option="--install-purelib=/usr/lib64/python2.7/site-packages" --no-deps ydk-models-cisco-ios-xe
/usr/lib/python3.4/site-packages/pip/commands/install.py:194: UserWarning: Disabling all use of wheels due to the use of --build-options / --global-options / --install-options.
cmdoptions.check_install_build_global(options)
Collecting ydk-models-cisco-ios-xe
Using cached ydk-models-cisco-ios-xe-16.6.1.post1.tar.gz
Installing collected packages: ydk-models-cisco-ios-xe
Running setup.py install for ydk-models-cisco-ios-xe ... done
Successfully installed ydk-models-cisco-ios-xe
[ehouby@mars samples]$ pip list
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.
asn1crypto (0.22.0)
bcrypt (3.1.3)
certifi (2017.11.5)
cffi (1.10.0)
chardet (3.0.4)
cryptography (2.0)
idna (2.6)
lxml (3.8.0)
ncclient (0.5.3)
paramiko (2.2.1)
pip (9.0.1)
pyang (1.6)
pyasn1 (0.3.3)
pybind11 (2.2.1)
pycparser (2.18)
PyNaCl (1.1.2)
requests (2.18.4)
setuptools (19.2)
six (1.10.0)
urllib3 (1.22)
ydk (0.6.2)
[ehouby@mars samples]$
[ehouby@mars samples]$ python bgp.py -h
Traceback (most recent call last):
File "bgp.py", line 29, in <module>
from ydk.types import Empty
ImportError: No module named types
[ehouby@mars samples]$
12-04-2017 03:47 PM
OK. That is strange. I just tried the same sequence on my centos and it works for me. Please find below the log:
[root@localhost ~]# cat /etc/*-release
CentOS Linux release 7.2.1511 (Core)
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"
CentOS Linux release 7.2.1511 (Core)
CentOS Linux release 7.2.1511 (Core)
Uninstall & install ydk:
[root@localhost ~]# pip list|grep ydk
[root@localhost ~]#
[root@localhost ~]# pip install ydk
Collecting ydk
Collecting pybind11>=2.1.1 (from ydk)
Using cached pybind11-2.2.1-py2.py3-none-any.whl
Installing collected packages: pybind11, ydk
Successfully installed pybind11-2.2.1 ydk-0.6.2
[root@localhost ~]# pip install --install-option="--install-purelib=/usr/lib64/python2.7/site-packages" --no-deps ydk-models-ietf
/usr/lib/python2.7/site-packages/pip/commands/install.py:188: UserWarning: Disabling all use of wheels due to the use of --build-options / --global-options / --install-options.
cmdoptions.check_install_build_global(options)
Collecting ydk-models-ietf
Using cached ydk-models-ietf-0.1.4.tar.gz
Installing collected packages: ydk-models-ietf
Running setup.py install for ydk-models-ietf ... done
Successfully installed ydk-models-ietf-0.1.4
You are using pip version 8.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Check installation:[root@localhost ~]# pip list|grep ydk
[root@localhost ~]# pip list|grep ydk
ydk (0.6.2)
ydk-models-ietf (0.1.4)
You are using pip version 8.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Import modules from python shell:
[root@localhost ~]# python
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 import types
>>> from ydk.models import ietf
>>>
12-04-2017 04:09 PM
FYI.. I have attached the verbose logs when installing ydk & ydk-models-ietf here.
12-04-2017 04:20 PM
It is working now after installing to /usr/lib64/python3.4/site-packages.
Thanks for the help.
-Eric
[root@mars samples]# pip install --install-option="--install-purelib=/usr/lib64/python3.4/site-packages" ydk-models-ietf
/usr/lib/python3.4/site-packages/pip/commands/install.py:194: UserWarning: Disabling all use of wheels due to the use of --build-options / --global-options / --install-options.
cmdoptions.check_install_build_global(options)
Collecting ydk-models-ietf
Using cached ydk-models-ietf-0.1.4.tar.gz
Requirement already satisfied: ydk>=0.6.1 in /usr/lib64/python3.4/site-packages (from ydk-models-ietf)
Requirement already satisfied: pybind11>=2.1.1 in /usr/lib/python3.4/site-packages (from ydk>=0.6.1->ydk-models-ietf)
Installing collected packages: ydk-models-ietf
Running setup.py install for ydk-models-ietf ... done
Successfully installed ydk-models-ietf-0.1.4
[root@mars samples]# 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.6.2)
ydk-models-ietf (0.1.4)
[root@mars samples]# python3 ./bgp.py -h
Usage: bgp.py [-h | --help] [options]
Options:
-h, --help show this help message and exit
-v VERSION, --version=VERSION
force NETCONF version 1.0 or 1.1
-u USERNAME, --user=USERNAME
-p PASSWORD, --password=PASSWORD
password
--proto=PROTO Which transport protocol to use, one of ssh or tcp
--host=HOST NETCONF agent hostname
--port=PORT NETCONF agent SSH port
[root@mars samples]#
12-04-2017 04:38 PM
Glad it worked! I didn’t realized you were using python3
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