mujoco icon indicating copy to clipboard operation
mujoco copied to clipboard

Expose viewer module when importing mujoco

Open WT-MM opened this issue 9 months ago • 2 comments

(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'>

WT-MM avatar Mar 10 '25 23:03 WT-MM

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.

google-cla[bot] avatar Mar 10 '25 23:03 google-cla[bot]

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

yuvaltassa avatar Mar 11 '25 03:03 yuvaltassa