A Virtual Environment is a self contained directory tree that contains a Python installation for a particular version of Python, plus a number of additional packages. To learn more about Virtual Environments see here
A Virtual Environment keeps all dependencies for the Python project separate from dependencies of other projects. This has a few advantages:
- It makes dependency management for the project easy.
- It enables using and testing of different library versions by quickly spinning up a new environment and verifying the compatibility of the code with the different version.
Requirement - Python 3.6 must be installed on the machine you would like to run ML-Agents on (either local laptop/desktop or remote server). Python 3.6 can be installed from here.
This guide has been tested with Python 3.6 and 3.7. Python 3.8 is not supported at this time.
- Download the
get-pip.pyfile using the commandcurl https://bootstrap.pypa.io/get-pip.py -o get-pip.py - Run the following
python3 get-pip.py - Check pip version using
pip3 -V
Note (for Ubuntu users): If the ModuleNotFoundError: No module named 'distutils.util' error is encountered, then
python3-distutils needs to be installed. Install python3-distutils using sudo apt-get install python3-distutils
- Create a folder where the virtual environments will reside
$ mkdir ~/python-envs - To create a new environment named
sample-envexecute$ python3 -m venv ~/python-envs/sample-env - To activate the environment execute
$ source ~/python-envs/sample-env/bin/activate - Verify pip version is the same as in the Installing Pip section. In case it is not the latest, upgrade to
the latest pip version using
$ pip3 install --upgrade pip - Install ML-Agents package using
$ pip3 install mlagents - To deactivate the environment execute
$ deactivate
- Install the python3-venv package using
$ sudo apt-get install python3-venv - Follow the steps in the Mac OS X installation.
- Create a folder where the virtual environments will reside
md python-envs - To create a new environment named
sample-envexecutepython -m venv python-envs\sample-env - To activate the environment execute
python-envs\sample-env\Scripts\activate - Verify pip version is the same as in the Installing Pip section. In case it is not the
latest, upgrade to the latest pip version using
pip install --upgrade pip - Install ML-Agents package using
pip install mlagents - To deactivate the environment execute
deactivate
Note:
- Verify that you are using Python 3.6 or Python 3.7. Launch a command prompt using
cmdand executepython --versionto verify the version. - Python3 installation may require admin privileges on Windows.
- This guide is for Windows 10 using a 64-bit architecture only.