Install

How to install motorcortex-python on Ubuntu or Windows.

This chapter explains how to install motorcortex-python. Select the operating system you are using:


Install Python 3

Motorcortex-python requires Python 3.10 or later. By default Python 3 is already installed on your Ubuntu distribution.

If it is not, install it with apt:

sudo apt install python3

Installing Motorcortex-python

Motorcortex-python is installed with the pip tool.

  1. Install pip so it can install Python packages:

    sudo apt install python3-pip
    
  2. Download, build and install the motorcortex-python package via pip:

    sudo -H pip3 install motorcortex-python
    

Motorcortex-python is now installed. Check it with python3 -c "import motorcortex; print(motorcortex.__version__)".

Install a virtual environment

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

Installing virtualenv
  1. Check whether a virtual environment tool is already installed:

    virtualenv --version
    
  2. If a version number appears it is already installed. If not, install virtualenv:

    sudo apt-get install virtualenv
    
Setting up virtualenv
  1. Create a directory for your virtual environment. You may choose any location:

    mkdir ~/virtualenvironment
    
  2. Create a folder for your new app that includes a clean copy of Python 3:

    virtualenv -p python3 ~/virtualenvironment/mcx-env
    
  3. Change into the new environment’s bin directory:

    cd ~/virtualenvironment/mcx-env/bin
    
  4. Activate the virtual environment:

    source activate
    

    The prompt now shows the environment name, in this case (mcx-env).

  5. To leave the virtual environment again, run:

    deactivate
    
Installing motorcortex-python in virtualenv
  1. With the environment active, download, build and install the motorcortex-python package via pip:

    pip3 install motorcortex-python
    

Motorcortex-python is now installed in your virtual environment.


Install Python 3.10 or later

Download Python 3 from the Python downloads page for Windows. Choose the appropriate installer for your system, and make sure it is Python 3.10 or later — motorcortex-python does not import on older versions.

  1. Launch the installer and choose Customize installation.

    The Python installer with Customize installation selected
  2. All options are selected by default (documentation and test suite are optional). Click Next.

    The Python installer optional features step
  3. Under the Advanced Options select Add Python to environment variables.

    The Python installer advanced options step
  4. Click Install.

Python 3 is now installed.

Installing Motorcortex-python

Motorcortex-python is the core library required for any Motorcortex client application. It provides convenient ways to communicate with Motorcortex-based applications.

Motorcortex-python is installed with the pip tool. You have to be connected to the internet to install packages using pip.

  1. Open a Command Prompt by pressing the Windows key and typing cmd.

  2. In the Command Prompt window type:

    python -m pip install motorcortex-python
    

The motorcortex-python package is now installed for the current user.

Alternative installation instructions

Alternatively you can use the Miniconda package and environment management system.

Install Miniconda Python 3

Download Miniconda Python 3 from the Miniconda documentation. Choose the appropriate installer for your system.

  1. Launch the installer.

  2. Click Next.

    The Miniconda installer welcome step
  3. Click I Agree.

    The Miniconda installer license agreement step
  4. Select who the installation is designated for and click Next.

    The Miniconda installer installation type step
  5. Choose your destination folder and click Next.

    The Miniconda installer destination folder step
  6. Select Register Anaconda as my default Python.

    The Miniconda installer advanced options step
  7. Click Install to start the installation.

  8. Click Finish to close the installer.

The Conda cheat sheet is a convenient reference when using Miniconda.

Create an environment

Open an Anaconda Prompt by pressing the Windows key, typing anaconda, and selecting it from the results.

  1. In the Anaconda Prompt window, create the mcx-env environment:

    conda create -n mcx-env python=3.10
    
    The Anaconda Prompt creating the mcx-env environment
  2. To remove an environment again, use:

    conda env remove -n mcx-env
    
Activate the environment

Activate the environment:

conda activate mcx-env

Next, to create your own Motorcortex-python application: Usage or Tools and examples.