|
| 1 | +import sys |
1 | 2 | import os
|
2 | 3 | import copy
|
3 |
| -from os.path import join, expanduser |
| 4 | +from os.path import join, expanduser, exists |
4 | 5 |
|
5 | 6 | import numpy as np
|
6 | 7 |
|
| 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 | +''' |
7 | 32 |
|
8 | 33 |
|
9 | 34 | def remove_empty_lines(string):
|
@@ -59,4 +84,16 @@ def discover_mujoco():
|
59 | 84 | mjpro_path = os.getenv('MUJOCO_PY_MJPRO_PATH')
|
60 | 85 | if not mjpro_path:
|
61 | 86 | 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 | + |
62 | 99 | return (mjpro_path, key_path)
|
0 commit comments