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

MuJoCo mjpython fails with uvx #8953

Open
kevinzakka opened this issue Nov 8, 2024 · 6 comments
Open

MuJoCo mjpython fails with uvx #8953

kevinzakka opened this issue Nov 8, 2024 · 6 comments
Labels
bug Something isn't working

Comments

@kevinzakka
Copy link

kevinzakka commented Nov 8, 2024

MuJoCo ships with an mjpython executable that is only needed on MacOS (related to launching UI on main thread). Unfortunately, running uvx --from mujoco mjpython on macOS fails with the following error message:

failed to dlopen path '/Users/kevin/Library/Caches/uv/archive-v0/FwmQkZOQj7kyCUmF_WcgC/bin/python': dlopen(/Users/kevin/Library/Caches/uv/archive-v0/FwmQkZOQj7kyCUmF_WcgC/bin/python, 0x000A): Library not loaded: @executable_path/../lib/libpython3.11.dylib
  Referenced from: <4C4C4423-5555-3144-A177-11E83484F9AC> /Users/kevin/.local/share/uv/python/cpython-3.11.10-macos-aarch64-none/bin/python3.11
  Reason: tried: '/Users/kevin/Library/Caches/uv/archive-v0/FwmQkZOQj7kyCUmF_WcgC/lib/python3.11/site-packages/mujoco/MuJoCo_(mjpython).app/Contents/lib/libpython3.11.dylib' (no such file), '/Users/kevin/Library/Caches/uv/archive-v0/FwmQkZOQj7kyCUmF_WcgC/bin/../lib/libpython3.11.dylib' (no such file), '/libpython3.11.dylib' (no such file)
@charliermarsh charliermarsh added the bug Something isn't working label Nov 9, 2024
@charliermarsh
Copy link
Member

Interesting. Does this only happen with uv-installed Pythons?

@kevinzakka
Copy link
Author

Hey @charliermarsh, thanks for getting back so quick!

It happens both with uvx, and if I install uv with pip then do uv pip install mujoco.

@zanieb
Copy link
Member

zanieb commented Nov 9, 2024

Does it happen with uvx --python-preference only-system --from mujoco mjpython?

@kevinzakka
Copy link
Author

Hi @zanieb, that actually works! Should I just run that all the time? Could you explain what's going on if possible?

@zanieb
Copy link
Member

zanieb commented Nov 9, 2024

Should I just run that all the time?

You could. Though using our managed distributions has various benefits, there are some short-coming for situations like this.

Could you explain what's going on if possible?

The distributions we include are "standalone" which means they're easy to distribute for a wide range of systems, but this means they have some quirks since it's a relatively new paradigm for Python distributions.

MuJoCo is looking for @executable_path/../lib/libpython3.11.dylib but it's using the wrong base path for the executable. It looks in a path relative to the virtual environment, e.g.: '/Users/kevin/Library/Caches/uv/archive-v0/FwmQkZOQj7kyCUmF_WcgC/bin/../lib/libpython3.11.dylib' but the file is actually at ~/.local/share/uv/python/cpython-3.11.10-macos-aarch64-none/lib/libpython3.11.dylib. There are various reasons this could be, e.g., if we are setting home to the wrong value in the pyvenv.cfg (though I thought we special-cased our own distributions).

There's sort of a similar issue in #8879

We're looking at fixing this behavior but it's a pretty hard problem.

@jonzamora
Copy link

Related issue, I encountered this a while back: google-deepmind/mujoco#1923

I didn't spend time finding a solution to this, and reverted back to using mamba for package management w/ MuJoCo in the meantime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants