dm_control: import MuJoCo, ImportError: cannot import name 'constants'

Dear all: when I import MuJoCo, some error happen:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-2-7bf9adbdec98> in <module>()
----> 1 import dm_control.mujoco

/Users/codeMan/Documents/py-lab/dm_control/dm_control/mujoco/__init__.py in <module>()
     16 """Mujoco implementations of base classes."""
     17
---> 18 from dm_control.mujoco.engine import action_spec
     19
     20 from dm_control.mujoco.engine import Camera

/Users/codeMan/Documents/py-lab/dm_control/dm_control/mujoco/engine.py in <module>()
     41
     42 from dm_control import render
---> 43 from dm_control.mujoco import index
     44
     45 from dm_control.mujoco import wrapper

/Users/codeMan/Documents/py-lab/dm_control/dm_control/mujoco/index.py in <module>()
     92 # Internal dependencies.
     93
---> 94 from dm_control.mujoco.wrapper import util
     95 from dm_control.mujoco.wrapper.mjbindings import sizes
     96 import numpy as np

/Users/codeMan/Documents/py-lab/dm_control/dm_control/mujoco/wrapper/__init__.py in <module>()
     21
     22
---> 23 from dm_control.mujoco.wrapper import mjbindings
     24
     25 from dm_control.mujoco.wrapper.core import callback_context

/Users/codeMan/Documents/py-lab/dm_control/dm_control/mujoco/wrapper/mjbindings/__init__.py in <module>()
     22 from absl import logging
     23
---> 24 from dm_control.mujoco.wrapper.mjbindings import constants
     25 from dm_control.mujoco.wrapper.mjbindings import enums
     26 from dm_control.mujoco.wrapper.mjbindings import sizes

ImportError: cannot import name 'constants'

My python version is Python 3.5.3, and I use macOs sierra 10.12.6

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 7
  • Comments: 19

Most upvoted comments

Did you install making it editable? This gave me the same problem. In other words, this doesn’t work

pip install -e <path_to_dm_control>

while this does work

pip install <path_to_dm_control>

I tend to always use the former when trying out new libraries, so I can edit them and see how they work. However, if you make the library editable, it doesn’t seem to generate the needed mjbindings.

This happens if you “pip install” but then try to import the module form the github source dir. change to some other path than the github checkout and it will work.