10-19-2019 02:47 AM
Hi, Python3 and Python3-pip installed successfully but when trying to install ydk-py using:
sudo -H pip3 install ydk-models-cisco-ios-xr
command "/usr/bin/python3 -u -c "import setuptools, tokenize;file='/tmp/pip-install-l1f6352_/ydk/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-record-gwkg0f1j/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-l1f6352_/ydk/
Solved! Go to Solution.
10-19-2019 08:59 AM
The YDK has never been tested on Ubuntu 19.04 platform. It is short term release, which support will expire in January 2020. We would recommend instead to use stable and well tested platform Ubuntu 18.04 LTS, which support is going to expire in 2023.
It was very difficult from your post to make conclusive judgement about what went wrong. Therefore I have installed Ubuntu 19.04 virtual box and then tested YDK installation. Here is history from my test with few comments.
# Install system requirements following documentation https://github.com/CiscoDevNet/ydk-gen#system-requirements
sudo apt-get install -y gdebi-core python3-dev libtool-bin
sudo apt-get install -y libcurl4-openssl-dev libpcre3-dev libssh-dev libxml2-dev libxslt1-dev cmake
# Check Python installation
python3 -V
pip3 -V
# Noted that pip3 is not installed. Install pip3
sudo apt install python3-pip
# Install and activate python virtual environment
sudo apt-get install python3-venv
python3 -m venv venv
source ./venv/bin/activate
# Install YDK C++ core library from artifactory
wget https://devhub.cisco.com/artifactory/debian-ydk/0.8.4/bionic/libydk-0.8.4-1.amd64.deb
sudo gdebi libydk-0.8.4-1.amd64.deb
# Tried to install YDK Python core package and cisco-ios-xr bundle
# Use '-v' option to see any possible failure
pip install -v ydk-models-cisco-ios-xr
# The installation failed due to CMake Error.
# The log showed that libssh-threads.so is missing
# Install libssh from source following https://github.com/CiscoDevNet/ydk-gen#libssh-installation
wget https://git.libssh.org/projects/libssh.git/snapshot/libssh-0.7.6.tar.gz
tar zxf libssh-0.7.6.tar.gz && rm -f libssh-0.7.6.tar.gz
mkdir libssh-0.7.6/build && cd libssh-0.7.6/build
cmake ..
sudo make install
cd -
# Install YDK Python core package and cisco-ios-xr bundle
pip install -v ydk-models-cisco-ios-xr
# Test YDK-Py installation
python -c "import ydk.types"
Please note that gcc-c++ default package version for Ubuntu 19.04 is 8.4, but libydk library from artifactory was built with compiler version 7.4. Although I did not see any errors during installation, I cannot guarantee that it is fully compatible with system libraries for gcc 8.4. If such issues surface out, you will need to recompile the C++ core library from source using native compiler. Please follow installation procedures documented in ydk-gen documentation on GitHub.
Good luck
Yan
10-19-2019 08:59 AM
The YDK has never been tested on Ubuntu 19.04 platform. It is short term release, which support will expire in January 2020. We would recommend instead to use stable and well tested platform Ubuntu 18.04 LTS, which support is going to expire in 2023.
It was very difficult from your post to make conclusive judgement about what went wrong. Therefore I have installed Ubuntu 19.04 virtual box and then tested YDK installation. Here is history from my test with few comments.
# Install system requirements following documentation https://github.com/CiscoDevNet/ydk-gen#system-requirements
sudo apt-get install -y gdebi-core python3-dev libtool-bin
sudo apt-get install -y libcurl4-openssl-dev libpcre3-dev libssh-dev libxml2-dev libxslt1-dev cmake
# Check Python installation
python3 -V
pip3 -V
# Noted that pip3 is not installed. Install pip3
sudo apt install python3-pip
# Install and activate python virtual environment
sudo apt-get install python3-venv
python3 -m venv venv
source ./venv/bin/activate
# Install YDK C++ core library from artifactory
wget https://devhub.cisco.com/artifactory/debian-ydk/0.8.4/bionic/libydk-0.8.4-1.amd64.deb
sudo gdebi libydk-0.8.4-1.amd64.deb
# Tried to install YDK Python core package and cisco-ios-xr bundle
# Use '-v' option to see any possible failure
pip install -v ydk-models-cisco-ios-xr
# The installation failed due to CMake Error.
# The log showed that libssh-threads.so is missing
# Install libssh from source following https://github.com/CiscoDevNet/ydk-gen#libssh-installation
wget https://git.libssh.org/projects/libssh.git/snapshot/libssh-0.7.6.tar.gz
tar zxf libssh-0.7.6.tar.gz && rm -f libssh-0.7.6.tar.gz
mkdir libssh-0.7.6/build && cd libssh-0.7.6/build
cmake ..
sudo make install
cd -
# Install YDK Python core package and cisco-ios-xr bundle
pip install -v ydk-models-cisco-ios-xr
# Test YDK-Py installation
python -c "import ydk.types"
Please note that gcc-c++ default package version for Ubuntu 19.04 is 8.4, but libydk library from artifactory was built with compiler version 7.4. Although I did not see any errors during installation, I cannot guarantee that it is fully compatible with system libraries for gcc 8.4. If such issues surface out, you will need to recompile the C++ core library from source using native compiler. Please follow installation procedures documented in ydk-gen documentation on GitHub.
Good luck
Yan
10-19-2019 11:55 AM
Thank you so much for all these efforts, steps and time you put on this.
I repeated all the steps just like you. No error or problem before:
# Install YDK Python core package and cisco-ios-xr bundle
pip install -v ydk-models-cisco-ios-xr
Got these 2 errors while running the command.
And at last
moha@ubuntu:~$ python -c "import ydk.types" Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: No module named ydk.types
I'll be so thankful if you can help me with the rest of the story.
10-19-2019 03:49 PM
Based on the error message, I believe you created Python 2.7 virtual environment instead of Python 3.7 or forgot to activate virtual environment.
Good luck
Yan
10-20-2019 01:28 AM - edited 10-20-2019 01:29 AM
Thank you so much. Definitely you are a guru.
I ended to this which I think shows it is Ok and I can now run python ydk codes on my Ubuntu instead of natively on the devices.
Created wheel for ydk: filename=ydk-0.8.4-cp27-cp27mu-linux_x86_64.whl size=1752869 sha256=0e8f84ba76f4c80b49624a217776905fa723c896a3e606cdfd34a971778207ac Stored in directory: /root/.cache/pip/wheels/a7/dc/c1/7a15c363e86da229be6d267037f8268139b805c74c4d35a719 Removing source in /tmp/pip-install-IZqlBN/ydk Successfully built ydk Installing collected packages: ydk, ydk-models-ietf, ydk-models-cisco-ios-xr
Successfully installed ydk-0.8.4 ydk-models-cisco-ios-xr-6.6.2 ydk-models-ietf-0.1.5.post2 Cleaning up... Removed build tracker '/tmp/pip-req-tracker-GDTGLB' (venv) mohammad@mohammad-ubuntu:~$ ohammad@mohammad-ubuntu:~$ python -c "import ydk.types" mohammad@mohammad-ubuntu:~$
Just two questions if you don't mind:
1- I'm not a Linux guy, would you tell me about this python venv? is it used just for installation or I should use it on my codes somehow and run them via this?
2- Am I allowed to point to your answer (link here) in Ask Ubuntu and git so they can know the answer too?
Best regards,
10-20-2019 10:55 AM
I am glad it worked for you.
Regarding your questions.
1. You are not required to install YDK in Python virtual environment. This is just a convenient and sometimes preferred way of building environment for your Python project, because it isolates your project environment from Python software installation. You can have as many Python virtual environment as you need for your multiple projects. And there is no need for sudo or root access when you need install Python packages. You can read more about it here.
2. No problem when you place links to the posts.
Thank you and good luck.
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