Skip to content

Commit d3dd75d

Browse files
authoredOct 19, 2018
Helpful messages (openai#311)
* print helpful message instead of get compile/load error * bump version
1 parent b92e105 commit d3dd75d

File tree

3 files changed

+40
-13
lines changed

3 files changed

+40
-13
lines changed
 

‎mujoco_py/builder.py

+1-11
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from lockfile import LockFile
2121
import subprocess
2222

23-
from mujoco_py.utils import discover_mujoco
23+
from mujoco_py.utils import discover_mujoco, MISSING_KEY_MESSAGE
2424

2525

2626
def get_nvidia_lib_dir():
@@ -483,16 +483,6 @@ def build_callback_fn(function_string, userdata_names=[]):
483483
return module.lib.__fun
484484

485485

486-
MISSING_KEY_MESSAGE = '''
487-
You appear to be missing a License Key for mujoco. We expected to find the
488-
file here: {}
489-
490-
You can get licenses at this page:
491-
492-
https://www.roboti.us/license.html
493-
494-
If python tries to activate an invalid license, the process will exit.
495-
'''
496486

497487

498488
def find_key():

‎mujoco_py/utils.py

+38-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,34 @@
1+
import sys
12
import os
23
import copy
3-
from os.path import join, expanduser
4+
from os.path import join, expanduser, exists
45

56
import numpy as np
67

8+
MISSING_KEY_MESSAGE = '''
9+
You appear to be missing a License Key for mujoco. We expected to find the
10+
file here: {}
11+
12+
You can get licenses at this page:
13+
14+
https://www.roboti.us/license.html
15+
16+
If python tries to activate an invalid license, the process will exit.
17+
'''
18+
19+
MISSING_MJPRO_MESSAGE = '''
20+
You appear to be missing MuJoCo. We expected to find the file here: {}
21+
22+
This package only provides python bindings, the library must be installed separately.
23+
24+
Please follow the instructions on the README to install MuJoCo
25+
26+
https://github.com/openai/mujoco-py#install-mujoco
27+
28+
Which can be downloaded from the website
29+
30+
https://www.roboti.us/index.html
31+
'''
732

833

934
def remove_empty_lines(string):
@@ -59,4 +84,16 @@ def discover_mujoco():
5984
mjpro_path = os.getenv('MUJOCO_PY_MJPRO_PATH')
6085
if not mjpro_path:
6186
mjpro_path = join(expanduser('~'), '.mujoco', 'mjpro150')
87+
88+
# We get lots of github issues that seem to be missing these
89+
# so check that mujoco is really there and raise errors if not.
90+
if not exists(mjpro_path):
91+
message = MISSING_MJPRO_MESSAGE.format(mjpro_path)
92+
print(message, file=sys.stderr)
93+
raise Exception(message)
94+
if not exists(key_path):
95+
message = MISSING_KEY_MESSAGE.format(key_path)
96+
print(message, file=sys.stderr)
97+
raise Exception(message)
98+
6299
return (mjpro_path, key_path)

‎mujoco_py/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
__all__ = ['__version__', 'get_version']
22

3-
version_info = (1, 50, 1, 62)
3+
version_info = (1, 50, 1, 63)
44
# format:
55
# ('mujoco_major', 'mujoco_minor', 'mujoco_py_major', 'mujoco_py_minor')
66

0 commit comments

Comments
 (0)
Please sign in to comment.