-
I am using the tagged version from gym_jiminy.envs.acrobot import AcrobotJiminyEnv
print("hello world")
env = AcrobotJiminyEnv()
env.reset()
env.replay() This is the ouput I get from: python hello_world.py WARNING:root:Boost.Python cannot be shared between modules. Importing bundled jiminy dependencies instead of system-wide install as fallback.
hello world
WARNING:root:Boost.Python cannot be shared between modules. Importing bundled jiminy dependencies instead of system-wide install as fallback.
hello world
Traceback (most recent call last):
File "/Users/mathiasw/.pyenv/versions/jiminy/lib/python3.10/site-packages/jiminy_py/viewer/viewer.py", line 1214, in connect_backend
client = Panda3dViewer(window_type='onscreen',
File "/Users/mathiasw/.pyenv/versions/jiminy/lib/python3.10/site-packages/jiminy_py/viewer/panda3d/panda3d_visualizer.py", line 1928, in __init__
self._app = Panda3dProxy(config)
File "/Users/mathiasw/.pyenv/versions/jiminy/lib/python3.10/site-packages/jiminy_py/viewer/panda3d/panda3d_visualizer.py", line 1755, in __init__
self.start()
File "/Users/mathiasw/.pyenv/versions/3.10.14/lib/python3.10/multiprocessing/process.py", line 121, in start
self._popen = self._Popen(self)
File "/Users/mathiasw/.pyenv/versions/3.10.14/lib/python3.10/multiprocessing/context.py", line 224, in _Popen
return _default_context.get_context().Process._Popen(process_obj)
File "/Users/mathiasw/.pyenv/versions/3.10.14/lib/python3.10/multiprocessing/context.py", line 288, in _Popen
return Popen(process_obj)
File "/Users/mathiasw/.pyenv/versions/3.10.14/lib/python3.10/multiprocessing/popen_spawn_posix.py", line 32, in __init__
super().__init__(process_obj)
File "/Users/mathiasw/.pyenv/versions/3.10.14/lib/python3.10/multiprocessing/popen_fork.py", line 19, in __init__
self._launch(process_obj)
File "/Users/mathiasw/.pyenv/versions/3.10.14/lib/python3.10/multiprocessing/popen_spawn_posix.py", line 42, in _launch
prep_data = spawn.get_preparation_data(process_obj._name)
File "/Users/mathiasw/.pyenv/versions/3.10.14/lib/python3.10/multiprocessing/spawn.py", line 154, in get_preparation_data
_check_not_importing_main()
File "/Users/mathiasw/.pyenv/versions/3.10.14/lib/python3.10/multiprocessing/spawn.py", line 134, in _check_not_importing_main
raise RuntimeError('''
RuntimeError:
An attempt has been made to start a new process before the
current process has finished its bootstrapping phase.
This probably means that you are not using fork to start your
child processes and you have forgotten to use the proper idiom
in the main module:
if __name__ == '__main__':
freeze_support()
...
The "freeze_support()" line can be omitted if the program
is not going to be frozen to produce an executable.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/Users/mathiasw/.pyenv/versions/jiminy/lib/python3.10/site-packages/jiminy_py/viewer/viewer.py", line 611, in __init__
Viewer.connect_backend(backend)
File "/Users/mathiasw/.pyenv/versions/jiminy/lib/python3.10/site-packages/jiminy_py/viewer/viewer.py", line 292, in fun_safe
return fun(*args, **kwargs)
File "/Users/mathiasw/.pyenv/versions/jiminy/lib/python3.10/site-packages/jiminy_py/viewer/viewer.py", line 1221, in connect_backend
raise RuntimeError(
RuntimeError: Something went wrong. Impossible to instantiate viewer backend.
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/mathiasw/.pyenv/versions/3.10.14/lib/python3.10/multiprocessing/spawn.py", line 116, in spawn_main
exitcode = _main(fd, parent_sentinel)
File "/Users/mathiasw/.pyenv/versions/3.10.14/lib/python3.10/multiprocessing/spawn.py", line 125, in _main
prepare(preparation_data)
File "/Users/mathiasw/.pyenv/versions/3.10.14/lib/python3.10/multiprocessing/spawn.py", line 236, in prepare
_fixup_main_from_path(data['init_main_from_path'])
File "/Users/mathiasw/.pyenv/versions/3.10.14/lib/python3.10/multiprocessing/spawn.py", line 287, in _fixup_main_from_path
main_content = runpy.run_path(main_path,
File "/Users/mathiasw/.pyenv/versions/3.10.14/lib/python3.10/runpy.py", line 289, in run_path
return _run_module_code(code, init_globals, run_name,
File "/Users/mathiasw/.pyenv/versions/3.10.14/lib/python3.10/runpy.py", line 96, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/Users/mathiasw/.pyenv/versions/3.10.14/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/Users/mathiasw/Code/misc/github/jiminy/hello_world.py", line 7, in <module>
env.replay()
File "/Users/mathiasw/.pyenv/versions/jiminy/lib/python3.10/site-packages/gym_jiminy/common/envs/generic.py", line 1109, in replay
self.simulator.render(
File "/Users/mathiasw/.pyenv/versions/jiminy/lib/python3.10/site-packages/jiminy_py/simulator.py", line 747, in render
viewer = Viewer(
File "/Users/mathiasw/.pyenv/versions/jiminy/lib/python3.10/site-packages/jiminy_py/viewer/viewer.py", line 648, in __init__
raise RuntimeError(
RuntimeError: Impossible to create backend or connect to it. render/replay triggers another run of the script ?? If I copy-paste the lines in an ipython, there is no problem. But if I do I have no issue running the Thanks for your help! EDIT, this script reproduce the problem, the call self.start in Panda3dProxy.init in
or even simpler (what does
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Yes, this behaviour is unfortunately expected on MacOS and Windows. The viewer is running in another process to prevent the GIL from getting on the way and slowdowning the main thread when the viewer is running. |
Beta Was this translation helpful? Give feedback.
Yes, this behaviour is unfortunately expected on MacOS and Windows. The viewer is running in another process to prevent the GIL from getting on the way and slowdowning the main thread when the viewer is running.
fork
multiprocessing mode is not available on Windows and not the default on MacOS because it is not reliable on this OS (and pretty fragile overall). Because of this limitation,spawn
is generally recommended. However, the latter requires guarding the main script behindif __name__ == '__main__':
. This is not necessary withipython
because it hacking the multiprocessing library to use some kind ofasyncio
mechanism instead, so it manages sub-processes completely differently.