2

Does webots support python3? If yes, how can I change the interpreter?

I need to use python3 in order to load other packages that I need, ros, pandas, numpy.

Dominique
  • 8,687
  • 9
  • 28
  • 67
Francesco Z
  • 154
  • 1
  • 12

1 Answers1

3

Yes, Webots supports Python 3:

https://cyberbotics.com/doc/guide/using-python

Webots comes with several precompiled Python libraries (at least one for Python 2 and one for Python 3, depending on your OS). It's recommended to install the same Python version.

You can change the Python command once for all from the Webots Preferences (In the "General" tab), or per controller by defining a config.ini file in the controller directory (reference: https://cyberbotics.com/doc/guide/controller-programming#languages-settings), for example:

[python]

COMMAND = python3

Once setup, you can install extra packages using pip: https://cyberbotics.com/doc/guide/using-python#libraries

FabienRohrer
  • 1,736
  • 2
  • 15
  • 26
  • Thank you, it worked! I have a new problem now, what if I need to source ~/.bashrc before running the controller to include additional packages – Francesco Z Apr 16 '19 at 12:36
  • Mmm, this is weird. After installing a pip package, you should be able to use it directly (Python interprets this on-the-fly). Would this deserve another question of stack overflow? – FabienRohrer Apr 16 '19 at 14:44