"mlagents-learn' is not recognized as an internal or external command, operable program or batch fil" (873393)

After following this video tutorial:

I get to the final command of entering:
mlagents-learn Assets\Karting\Prefabs\AI\kart_mg_trainer_config.yaml --train --run-id=custom-track-1

but I only get this error:
‘mlagents-learn’ is not recognized as an internal or external command,
operable program or batch file.

Have you created a virtual environment i.e. conda environment and installed ml-agents toolkit using pip or so into that environment ? You should be able to run the shell file as followed:

  1. conda activate //anaconda3/envs/UnityML
  2. cd /Users/last_name/project_location
  3. chmod +x your_shell_file.sh
  4. ./your_shell_file.sh

Idk I just followed the video, do I just need to enter these commands or download something? It doesn’t say anything about anaconda, but I am wanting to use TensorFlow

  1. ml-agents/docs/Getting-Started.md at main · Unity-Technologies/ml-agents · GitHub

  2. ml-agents/docs/Installation.md at main · Unity-Technologies/ml-agents · GitHub

Still doesn’t work even after cloning the repository

Not sure what to say except that it works fine for me.

Something is wrong with your environment. Maybe its the Python installation. Maybe its some of the dependencies. etc…

I’ve completely reinstalled everything multiple times and tried multiple versions, desperate for it to work

Just out of curiosity
Did you cd to the directory where ML Agents is installed before running
mlagents-learn

in my case
cd D:\MLUnity\ml-agents

I restarted it all again and followed through the website instead: https://learn.unity.com/tutorial/karting-mod-smart-karts-training-guide#
so the mlagents is installed through the command prompt, so I do not know where the directory would be for me?
I am currently just trying to run it from my project directory

Any chance you have a discord so I can show you screenshots and stuff easier / quicker? No worries if not.

Its a path error. ML Agents is installed somewhere but that somewhere is not on the path.

Simplest way:
Download ML Agents Zip from GIT and unzip into a folder (or GIT Clone into a folder)

Goto that folder in the python terminal window.
Install the requirements / dependencies like Torch etc… (Probably already installed in your case but no harm either way)

Then from the folder where you downloaded ML Agents or Git Cloned it.

pip3 install -e ./ml-agents-envs
pip3 install -e ./ml-agents

At this point ML Agents is now installed in the folder where you downloaded it to or git cloned it to. Goto that folder and run mlagents-learn

Thanks that stuff is good now I think, I also downloaded torch as I saw that on another thread. I now just get the error:
Couldn’t connect to trainer on port 5004 using API version 1.0.0. Will perform inference instead.
I see people recommending to have the same version of C# and python but not sure how to check and other solutions for this didn’t work.
7972359--1022820--upload_2022-3-17_17-36-44.png