question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

import MuJoCo, ImportError: cannot import name 'constants'

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:6
  • Comments:19

github_iconTop GitHub Comments

18reactions
efagerhocommented, Jan 4, 2018

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.

4reactions
powderluvcommented, Apr 6, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ImportError: cannot import name constants - python
It looks like you have two versions installed. Try starting over. Remove all pyzmq packages and re-install it (using pip or whatever). –...
Read more >
ImportError: cannot import name 'constants' - Google Groups
You received this message because you are subscribed to the Google Groups "TRex Traffic Generator" group. To unsubscribe from this group and stop...
Read more >
Python Bindings - MuJoCo Documentation
Once installed, the package can be imported via import mujoco . Structs, functions, constants, and enums are available directly from the top-level mujoco...
Read more >
mujoco - PyPI
This package is the canonical Python bindings for the MuJoCo physics engine. ... Once installed, the package can be imported via import mujoco...
Read more >
Installing MuJoCo to Work With OpenAI Gym Environments
In this article, I'll show you how to install MuJoCo on your Mac/Linux ... or running python3 -c 'import mujoco_py' then follow these...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found