Skip to content

Expose viewer module when importing mujoco #2492

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

WT-MM
Copy link

@WT-MM WT-MM commented Mar 10, 2025

(base) wesleymaa@MacBook-Pro ~ % python
Python 3.11.11 | packaged by conda-forge | (main, Dec  5 2024, 14:21:42) [Clang 18.1.8 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import mujoco
>>> mujoco.viewer
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'mujoco' has no attribute 'viewer'
>>> 

The mujoco.viewer module is not re-imported, so code that tries to call it will fail. This is obscured on MacOS because using mjpython seems to add the module to path already or otherwise import it.

This PR re-imports mujoco.viewer

(base) wesleymaa@MacBook-Pro ~ % mjpython
Python 3.11.11 | packaged by conda-forge | (main, Dec  5 2024, 14:21:42) [Clang 18.1.8 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import mujoco
>>> mujoco.viewer
<module 'mujoco.viewer' from '/Users/wesleymaa/.conda/envs/ksim/lib/python3.11/site-packages/mujoco/viewer.py'>

Copy link

google-cla bot commented Mar 10, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@yuvaltassa
Copy link
Collaborator

yuvaltassa commented Mar 11, 2025

Thanks! Can you please do the CLA thing? (Update: sorry! you did that 🙂 )

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

Successfully merging this pull request may close these issues.

2 participants