Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with Building Python Bindings for YARP 3.11 in a pyenv Python 3.8 Environment #3191

Open
aatish1741 opened this issue Mar 12, 2025 · 4 comments

Comments

@aatish1741
Copy link

Hello,

I'm experiencing difficulty building YARP's Python bindings using YARP 3.11 on Ubuntu 22.04 in a pyenv virtual environment with Python 3.8. Despite several attempts, the resulting site‑packages directory in my virtual environment does not include a YARP module, and I receive a “ModuleNotFoundError: No module named 'yarp'” when trying to import it in Python.

Here’s what I've tried so far:

  • I set up a pyenv virtual environment (yarp-env) using Python 3.8.12.

  • I installed the necessary build dependencies, including SWIG 4.0.2 and development libraries.

  • I cleaned the build directory and reconfigured CMake with explicit parameters:
    cmake .. \ -DENABLE_yarp_python=ON \ -DPYTHON_EXECUTABLE=/home/myuser/.pyenv/shims/python \ -DPYTHON_LIBRARY=/home/myuser/.pyenv/versions/3.8.12/lib/libpython3.8m.so \ -DPYTHON_INCLUDE_DIR=/home/myuser/.pyenv/versions/3.8.12/include/python3.8 \ -DCMAKE_INSTALL_PREFIX=$(pyenv prefix)

  • I verified that CMake detected the pyenv Python executable, but in the CMakeCache.txt, the PYTHON_EXECUTABLE variable remains uninitialized or doesn’t reflect the full configuration.

  • I ran make and make install (without sudo, to install into my virtual environment) and checked my venv’s site‑packages directory—yet no YARP module appears.

  • I have also attempted to use alternative Python library names (e.g., checking for libpython3.8.so vs. libpython3.8m.so), but the issue persists.

  • I suspect there might be a compatibility issue with YARP 3.11’s Python bindings and this environment. Has anyone encountered similar issues or have suggestions on how to resolve this? Any help would be greatly appreciated.

Thank you in advance for your assistance!

@traversaro
Copy link
Member

I do not have direct experience with pyenv, but the issue seems that the yarp python extension is not installed in the place expected by pyenv. Can you report your pip list --verbose, and the list of files installed (it is contained in a file called install_manifest.txt). Those may be helpful for you for solving your issue.

As a general comment instead, please note that YARP build process uses a lot of C++ dependencies that need to be obtained somewhere outside of pyenv, so you library will not be isolated from your environment. For this reason most of the time if we need to use C++ libraries with many dependencies in a virtual environment, we tend to use conda/pixi environments that also manage in an isolated way the C++ dependencies, not only the Python ones.

@aatish1741
Copy link
Author

i tried running the pip list --verbose and also checked the install manifest.txt files, it seems that i am not able to install the python bindings, which i tried through various ways, at first i tried throuhg normal python version 3.10, but it didn't work, then i tried with pyenv and its still not working. can you suggest me some ways please? will downgrading my yarp version from 3.11 to 3.8 or 3.9 or 3.10 work?

@traversaro
Copy link
Member

Did you enabled the YARP_COMPILE_BINDINGS and CREATE_PYTHON CMake options as documented in https://www.yarp.it/latest/yarp_swig.html#yarp_swig_python ?

@aatish1741
Copy link
Author

Hello, Thank You for the help, i didn't enable the yarp_compile_bindings. Now it is working fine. Really appreciate it a lot!! Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants