Win 10, Win 11 install MuJoCo and mujoco-py tutorial

The specific configuration information for this installation tutorial is as follows:

Date: 2022.07.25
OS: Windows 11
python version: 3.9.0
mujoco version: mjpro150
mujoco-py version: 1.50.1.0
gym version: 0.13.0

1. Installation Preface

1.1 Basic instructions for installation

This installation tutorial is based on the Windows system, mainly for the convenience of subsequent comparative experiments on Reinforcement Learning (RL) algorithms. And the creation background of this tutorial is: most of the current tutorials were written before MuJoCo was acquired by DeepMind, and the installation process is rugged, and there are many hidden pits.

It should be noted that currently MuJoCo is mainly applicable to Linux system or MacOS system, and the most perfect version for Windows system is mjpro150 and mujoco-py 1.50.1.0.

1.2 Description of MuJoCo

MuJoCo was originally developed by Emo Todorov, a neuroscientist and director of the Motion Control Laboratory at the University of Washington in the United States. It was built into a commercial product in 2015 through the startup company Roboti LLC.

In October 2021, DeepMind announced the acquisition of the MuJoCo physics simulator and promised to develop and maintain MuJoCo as a free, open source, community-driven project.

In short, the ownership of MuJoCo Roboti LLChas changed the present DeepMind, but Roboti LLC still retains the official website of the old version of MuJoCo: MuJoCo (roboti.us)

  • Note: The links to the old version of MuJoCo provided in other posts cannot be opened. After careful comparison, it is found that Roboti LLC deleted the URL before www..

1.3 mujoco-py Description

The mujoco-py Github address officially provided by OpenAI: openai/mujoco-py: MuJoCo is a physics engine for detailed, efficient rigid body simulations with contacts. mujoco-py allows using MuJoCo from Python 3. (github.com)

The version that supports Windows 10 / Windows 11 is v1.50.1.0 : Release v1.50.1.0 openai/mujoco-py (github.com)

2. Specific installation process

2.0 Installation file sharing

In order to prevent interference from factors such as network failures, I have packaged and uploaded all the files required for installation to Baidu Netdisk . The specific link is as follows: Environment required for mujoco installation_Free high-speed download|Baidu Netdisk-Share Unlimited (baidu .com)

2.1 Install Visual Studio Build Tools

The installation of this part is also the main reason for me to write this blog, because I still can't run the corresponding program normally after installing according to the installation tutorial provided on the Internet, and after investigation, it is the error in this part. Moreover, this part of the online tutorial does not provide the corresponding verification test for successful installation, so it is still a very important part for the program to run successfully in the end!

This step is indispensable in the whole installation process, because the mujoco simulation engine is based on C/C++, so each run is actually compiled and converted by VS Build Tools. Here is the official website of Microsoft Visual Studio: Download Visual Studio Tools - Free Installation for Windows, Mac, Linux (microsoft.com)

If you decide to install the 22 version of visual studio build tools, you can directly find 所有下载-适用于 Visual Studio 2022 的工具-Visual Studio 2022 生成工具and , as shown in Figure 1 below :

insert image description here

Figure 1. Visual Studio 2022 build tools download page

Of course, if you want to install the previous version of the build tool, you can find it yourself in the earlier downloads at the bottom.

In section 2.0 installation file sharing, I have added three files, vs_buildtools_2017.exe, vs_buildtools_2019.exe and vs_buildtools_2022.exe, to Baidu Netdisk, and they can be used if necessary.

I tested vs_buildtools 2017, vs_buildtools 2019 and vs_buildtools 2022 during the installation process in a few days, and they should all be able to be successfully installed. What needs to be explained is that some posts say to install vs_buildtools 2015, and it will prompt during the actual installation process. visual studio C++ build tools 安装包丢失或毁坏If you must install vs_buildtools 2015 version, here is a corresponding solution: to solve the missing or missing installation package when visual studio C++ build tools The problem of damage (pro test is definitely useful!!!)_Aaron-ywl's Blog-CSDN Blog

Finally, I installed vs_buildtools_2017.exe, and the interface selected during installation is shown in Figure 2:

insert image description here

Figure 2. vs_buildtools_2017.exe installation selection interface

Some other tutorials say that you only need to check Windows 10 SDKto complete this step. In my actual installation test, the program cannot run normally, so it is recommended to check it Visual C++ 生成工具, and the overall hard disk space occupied will not be much.

2.2 Install mjpro150 and mujoco-py

For this part, you can refer to the following post. The installation idea is clear, and there are corresponding screenshots for each step: [Mujoco] Installation under Win10 - Zhihu (zhihu.com)

3. Part of the error description when running the program

3.1 ImportError: DLL load failed while importing cymj

This error is reported because the version of Python is higher. Since Python 3.8, it will only be loaded when the program is running trusted dlls. There is a corresponding Issue on Github for this problem. For details, please refer to: ImportError: DLL load failed while importing cymj: The specified module could not be found. · Issue #638 · openai/mujoco-py (github.com)

The solution is to run every time the Python version of Python 3.8 and above

import mujoco_py

The following three lines of commands need to be run before the command:

import os
os.add_dll_directory("C://Users//XXX//.mujoco//mjpro150//bin")
os.add_dll_directory("C://Users//XXX//.mujoco//mujoco-py-1.50.1.0//mujoco_py")

Among them, in the path XXXis the actual administrator user name on your computer, which needs to be modified accordingly.

3.2 distutils.errors.DistutilsExecError

This is a very common error report. Here is an example of an error report:

CompileError: command ‘C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.29.30133\bin\HostX86\x64\cl.exe’ failed with exit status 2

cl : Command line warning D9025 : overriding ‘/W3’ with ‘/w’ cl : Command line warning D9002 : ignoring unknown option ‘-fopenmp’

The reason for the error and the corresponding solution are also given on GitHub, specifically because the path name installed on the computer is too long, including the Python installation path name and the vsbuildtools installation path name. For the specific corresponding Issue on Github, see: Fatal error - file name too long · Issue #298 · openai/mujoco-py (github.com)

3.3 Other errors

This installation blog - Windows 10 installation of open source Mujoco - Zhihu (zhihu.com) also gave a reason for the error at the end: Visual Studio, visual studio SDK is not installed on the same disk as anaconda, python, pycharm, specifically I I did not encounter it during the installation process. If any friends encounter related problems during the installation process, they can refer to it accordingly.

Guess you like

Origin blog.csdn.net/alan1ly/article/details/126087866