Open ghost opened 7 years ago
Currently, there is a need to rebuild python library on some CentOS environments with --enable-shared
option to compile ydk-py. Could be fixed with #626
You may face the below issues when doing something like pip install ydk
on CentOS:
You may see something like the below error:
...
[100%] Linking CXX shared module ../lib.linux-x86_64-2.7/ydk_.so
/usr/bin/ld: /usr/local/lib/libpython2.7.a(abstract.o): relocation R_X86_64_32S against `_Py_NotImplementedStruct' can not be used when making a shared object; recompile with -fPIC
...
To fix this, you need to compile the python installation with the --enable-shared option as follows (steps obtained from google search):
cd <compilation-directory>
tar jvzf Python-2.7.tar.bz2
cd Python-2.7
./configure --enable-shared [--prefix=/your/custom/installation/path]
make
make test
make install
...
python version: 3.6m
-- Found PythonLibs: /usr/local/lib/libpython2.7.a (found version "2.7")
pybind11 include: /root/user/Python-3.6.2/include/python3.6m;/root/.local/include/python3.6m
...
[100%] Linking CXX shared module ../lib.linux-x86_64-3.6/ydk_.so
/usr/bin/ld: /usr/local/lib/libpython2.7.a(abstract.o): relocation R_X86_64_32S against `_Py_NotImplementedStruct' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libpython2.7.a: error adding symbols: Bad value
...
To fix this, please set the below environment variables before running 'pip install ...' For example, in bash:
export CMAKE_INCLUDE_PATH=/root/path_of_python_installation/Python-3.6.2/include
export CMAKE_LIBRARY_PATH=/root/path_of_python_installation/Python-3.6.2/lib
pip
, another option is to use easy_install
to install ydk-models-openconfig & other bundles
$ sudo easy_install -v --install-dir="/usr/lib64/python2.7/site-packages" ydk-models-ietf
$ sudo easy_install -v --install-dir="/usr/lib64/python2.7/site-packages" ydk-models-openconfig
$ sudo easy_install -v --install-dir="/usr/lib64/python2.7/site-packages" ydk-models-cisco-ios-xr
devtools-4 are no longer available on centos 7.
Using default compiler gave me this error when importing ydk.services: undefined symbol: _ZSt24__throw_out_of_range_fmtPKcz
furthermore, --install-purelib option does not work with recent pip versions
Here's what worked for me: ` [root@controller ~]# yum install devtoolset-7-gcc* [root@controller ~]# ln -sf /opt/rh/devtoolset-7/root/usr/bin/gcc /usr/bin/cc [root@controller ~]# ln -sf /opt/rh/devtoolset-7/root/usr/bin/g++ /usr/bin/c++
pip3 install --target="/usr/local/lib64/python3.6/site-packages" --no-deps ydk-models-ietf ydk-models-openconfig ydk-models-cisco-ios-xr ydk-models-cisco-ios-xe --upgrade pip3 install ydk `
ydk 0.6.0
installation for core so that cmake3 or cmake is used without having to link the binaryydk installation should not assume shared library for python is installed