Setting up Libraries
Caveats
While RoboCo generally supports the use of external libraries, the following caveats need to be taken into account.
RoboCo uses a very specific installation of Python which might not be supported by all libraries
When you share a robot, you’ll also need to help the recipient install any libraries that the robot uses
This should not be circumvented by installing modules from within your script
Pip doesn’t support installing modules from within a script
Scripts shared via official channels should not perform system operations
The Python installation doesn’t have all of the default tools that other Python installations might have, so you might need to acquire them as necessary
Installation
When you run RoboCo for the first time it will install a copy of Python in this folder:
%userprofile%\AppData\LocalLow\Filament Games\RoboCo\python\Interpreter-ModifyWithCare\python-3.9.6-embed-amd64
.
You should be able to open command prompt and type in the following to check the version of pip.
cd %userprofile%\\AppData\\LocalLow\\Filament Games\\RoboCo\\python\\Interpreter-ModifyWithCare\\python-3.9.6-embed-amd64
python.exe -m pip -v
From there you can install python packages as you would in any other circumstance. Make sure to directly call
the Python exe inside that folder, not the python that’s in your %PATH%
otherwise you’ll install libraries to
that installation of Python.
This command will install the numpy
package.
python.exe -m pip install numpy
Alternative Method
While not technically supported, it is possible to redirect RoboCo to a different installation of Python.
The game is only tested with the embedded installation of Python 3.9.6, but it is possible that you might
need a different installation for one reason or another. In that case, you can find a file called python-location.json
inside of your copy of RoboCo. It is located at RoboCo_Data\StreamingAssets\Python\python-location.json
and it should
contain the following:
{
"pythonPath": "%PERSISTENTDATAPATH%\\python\\Interpreter-ModifyWithCare\\python-3.9.6-embed-amd64",
"pythonDll": "%PERSISTENTDATAPATH%\\python\\Interpreter-ModifyWithCare\\python-3.9.6-embed-amd64\\python39.dll"
}
If you change the first path to a folder containing your python interpreter and the second to the dll in that folder, then (when you next start the game) RoboCo will try to use that interpreter instead of the embedded one which comes with it. Once you’ve done that, any libraries that you have installed on that installation will be accessible from in the game. There are no garauntees that the RoboCo API will work with any given version of Python or even any installation of 3.9.6, but you are free to play around and see what works for you.