MCX-Python Installation

3 minute read

This chapter will explain how to install mcx-python. Please select the operating system you are u using:

Linux Linux Windows Windows Windows MacOS

Installing Motorcortex-Python for Linux

Installing Python 3.7 or lower

Python 3 should already be installed by default on your modern Linux distribution.

  1. Check if your version is Python 3.7 or lower.
python --version

If the version is 3.7 or below, you are good to go.

  1. If the version is 3.8 or higher, install Python 3.7 and set it as default. This is done by following the actions below.
sudo apt install python3.7
sudo update-alternatives --config python
  1. The last command will show you an error:
“update-alternatives: error: no alternatives for python”.
  1. Run the commands below, where instead of “3.x” you fill-in the version is you obtained when running python –version.
sudo update-alternatives --install /usr/bin/python python
/usr/bin/python**3.x** 1

sudo update-alternatives --install /usr/bin/python python
/usr/bin/python3.6 2
  1. After that run the command below and select python 3.7.
sudo update-alternatives --config python

Installing Motorcortex-Python

motorcortex-python can be installed by using the pip tool.

  1. To be able to use pip to install python packages this first needs to be installed:
sudo apt install python3-pip
  1. Then download, build and install the motorcortex-python package via pip.
sudo -H pip3 install motorcortex-python

This will install motorcortex-python for Python3 for all users.

Installation Instructions using virtual environment

MOTORCORTEX-python can also be installed inside a virtual environment. This can be useful if your system has a different python environment that the one required for MOTORCORTEX or if you would like to keep the MOTORCORTEX-python tools separate from the rest of the system for security reasons. A Virtual Environment, is an isolated working copy of Python which allows you to work on a specific project without worry of affecting other projects.

Installing Virtualenv

  1. Check if virtual environment is already installed on your system you can check this using the following command:
virtualenv --version
  1. If you see a version number for instance 1.6.1 it is already installed. If not you will have to install Vitrualenv:
sudo apt-get install virtualenv

Setting up Vitrualenv

  1. You will need a directory for your virtual enviroment. You may choose any location you desire:
mkdir ~/virtualenvironment
  1. To create a folder for your new app that includes a clean copy of Python3 run:
virtualenv -p python3 ~/virtualenvironment/mcx-env
  1. We have created this new folder called mcx-env. To begin cd into your new project:
cd ~/virtualenvironment/mcx-env/bin
  1. Now you are in your virtual environment folder you can activate your virtual environment:
source activate
  1. Notice your prompt will have a shell in this case (mcx-env). If you would like to leave your virtual environment type the following command:

Installing Motorcotex-Python in Vitrualenv

  1. Motorcortex-python can be installed by using the “pip” tool. download, build and install the motorcortex-python package via pip.
pip3 install motorcortex-python

Motorcortex-python is now installed in your virtual environment.

Last modified March 23, 2021: Restructured GRID (44d0658)