mcmtroffaes / pycddlib

A Python wrapper for Komei Fukuda's cddlib.
http://packages.python.org/pycddlib/
GNU General Public License v2.0
61 stars 9 forks source link

Help Regarding Installation #63

Closed arshad171 closed 1 year ago

arshad171 commented 1 year ago

Hi,

I have a Fedora production server where I am trying to install cdd. I came across the following documentation and installed the required dependencies

(rl-mo-env) [arshad@cloud-01 rl-crazyflie]$ dnf list --installed | grep 'gmp-devel\|python3-devel'
gmp-devel.x86_64                                     1:6.2.1-4.fc38                       @release                  
python3-devel.x86_64                                 3.11.4-1.fc38                        @Fedora.updates  

And then I could install pycddlib by first setting the include path and then pip install

(rl-mo-env) [arshad@cloud-01 rl-crazyflie]$ export CPPFLAGS=-I/usr/include/python3.11/
(rl-mo-env) [arshad@cloud-01 rl-crazyflie]$ pip install pycddlib --no-cache-dir
Collecting pycddlib
  Downloading pycddlib-2.1.7.tar.gz (159 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 159.3/159.3 kB 6.0 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: pycddlib
  Building wheel for pycddlib (setup.py) ... done
  Created wheel for pycddlib: filename=pycddlib-2.1.7-cp39-cp39-linux_x86_64.whl size=959295 sha256=bf3756b09881cfc5bbb8d0b4a41904dd54307c8b3df5608741a18ed520b66cdd
  Stored in directory: /tmp/pip-ephem-wheel-cache-239xpvtp/wheels/98/17/36/aad8bfb8adccab39c7e94d60593c23a4f75ef4c5223f2d73ca
Successfully built pycddlib
Installing collected packages: pycddlib
Successfully installed pycddlib-2.1.7

However, I am unable to use or even import the library in my python code I see the following error undefined symbol: PyDescr_IsData

(rl-mo-env) [arshad@cloud-01 rl-crazyflie]$ python
Python 3.9.18 (main, Sep  6 2023, 16:41:18) 
[GCC 13.2.1 20230728 (Red Hat 13.2.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cdd
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: /home/data/arshad/workspace/rl-crazyflie/rl-mo-env/lib/python3.9/site-packages/cdd.cpython-39-x86_64-linux-gnu.so: undefined symbol: PyDescr_IsData
>>> 

I would really appreciate your help!

Thanks, Arshad

mcmtroffaes commented 1 year ago

There seems to be a mix of python version in play (I see both 3.11 and 3.9 in different parts of your build), so if I had to venture a guess, that's probably why it's not working.

arshad171 commented 1 year ago

@mcmtroffaes Thanks for the quick reply!

There seems to be a mix of python version in play (I see both 3.11 and 3.9 in different parts of your build), so if I had to venture a guess, that's probably why it's not working.

You were right. When I created a python3.11 virtual env and installed pycddlib, it worked and I was able to use the library.

However, I would like to have python3.9 for my work (due to compatibility issues).

So tried I having an isolated Anaconda environment, but I see the same error as before.

I also tried setting CPPFLAGS to point to python3.9 (unlike I had it pointing to python3.11 before). The installation went through, however, I still see the same error when trying to import the lib

(rl-mo-env) [arshad@cloud-01 ~]$ python --version
Python 3.9.18
(rl-mo-env) [arshad@cloud-01 ~]$ which python
/work/arshad/anaconda3/envs/rl-mo-env/bin/python
(rl-mo-env) [arshad@cloud-01 ~]$ pip list | grep dev
devtools                  0.12.2
(rl-mo-env) [arshad@cloud-01 ~]$ echo $CPPFLAGS
-I/usr/include/python3.9/
(rl-mo-env) [arshad@cloud-01 ~]$ pip install pycddlib
Collecting pycddlib
  Using cached pycddlib-2.1.7-cp39-cp39-linux_x86_64.whl
Installing collected packages: pycddlib
Successfully installed pycddlib-2.1.7
(rl-mo-env) [arshad@cloud-01 ~]$ python -c "import cdd"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: /work/arshad/anaconda3/envs/rl-mo-env/lib/python3.9/site-packages/cdd.cpython-39-x86_64-linux-gnu.so: undefined symbol: PyDescr_IsData
mcmtroffaes commented 1 year ago

I'm glad you managed to make it work with Python 3.11.

As a next step for the Python 3.9 build, I suggest using "python -m pip install pycddlib" instead of "pip install pycddlib", that way you know 100% for sure you're using the pip that fits the correct python installation. Though the venv should get this right... but I can't see where else it might be going wrong.

Either way PyDescr_IsData is part of the Python API (for both python 3.9 and 3.11) so it looks like a shared library loading issue not specific to pycddlib itself (as far as I can tell).

mcmtroffaes commented 1 year ago

Also note it's using the cached version which might still be corrupted. Try clearing the cache first before the build.

arshad171 commented 1 year ago

Thank you!

That worked. Setting the CPPFLAGS to python 3.9 and using --no-cache did a clean build