Install
4 minute read
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.
-
Install
pipso it can install Python packages:sudo apt install python3-pip -
Download, build and install the motorcortex-python package via pip:
sudo -H pip3 install motorcortex-pythonNote
This installs motorcortex-python for Python 3 for all users. On Ubuntu 23.04 and later,
piprefuses to install into the system Python; use a virtual environment as described below.
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
-
Check whether a virtual environment tool is already installed:
virtualenv --version -
If a version number appears it is already installed. If not, install
virtualenv:sudo apt-get install virtualenv
Setting up virtualenv
-
Create a directory for your virtual environment. You may choose any location:
mkdir ~/virtualenvironment -
Create a folder for your new app that includes a clean copy of Python 3:
virtualenv -p python3 ~/virtualenvironment/mcx-env -
Change into the new environment’s
bindirectory:cd ~/virtualenvironment/mcx-env/bin -
Activate the virtual environment:
source activateThe prompt now shows the environment name, in this case
(mcx-env). -
To leave the virtual environment again, run:
deactivate
Installing motorcortex-python in virtualenv
-
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.
-
Launch the installer and choose
Customize installation.
-
All options are selected by default (documentation and test suite are optional). Click
Next.
-
Under the Advanced Options select
Add Python to environment variables.
-
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.
-
Open a
Command Promptby pressing theWindowskey and typingcmd.Note
It may be necessary to use
Run as administratorif the installation command fails. -
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.
-
Launch the installer.
-
Click
Next.
-
Click
I Agree.
-
Select who the installation is designated for and click
Next.
-
Choose your destination folder and click
Next.
-
Select
Register Anaconda as my default Python.
-
Click
Installto start the installation. -
Click
Finishto 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.
-
In the Anaconda Prompt window, create the
mcx-envenvironment:conda create -n mcx-env python=3.10
-
To remove an environment again, use:
conda env remove -n mcx-env
Activate the environment
Activate the environment:
conda activate mcx-env
Note
To access this environment another time, open an Anaconda Prompt window and type conda activate mcx-env. To deactivate an environment type conda deactivate.
Next, to create your own Motorcortex-python application: Usage or Tools and examples.