Python script: Installation

Python Scripting: Installation

The Python Scripting Element is compiled using Python 3.6 and the Python library is linked dynamically, therefore, to use it, the same version of Python should be installed.

Prerequisites

  • Python 3.6
  • Python packages: Jupyter Qt Console (v.4.3.1), numpy (v.1.14)
  • For Mac OS: Jupyter QtConsole should be installed with Qt Framework v.5.9

Tested installations

The Pythons Scripting Element is compiled using a specific version of Python library, therefore, to use it, the same version of Python should be installed:

  • Windows: Anaconda3 v.5.2, Python v.3.6.5 (64 bit), Jupyter QtConsole v.4.3.1, numpy v.1.14
  • Linux: Anaconda3 v.5.1, Python v.3.6.4 (64 bit), Jupyter QtConsole v.4.3.1, numpy v.1.14.3
  • Mac: installation via Homebrew, Python v.3.6.3, Jupyter QtConsole v.4.3.1

Installation
Installation consist of 2 steps:

  1. Add the Python Scripting Element
  2. Install Python 3.6 and Jupyter Qt Console

Installation of Python

Windows, Linux

Please, see the list of tested installations for the version to install.

For Windows and Linux, we recommend installing Python via Anaconda. The Anaconda installer contains the conda manager, Python, and the most used packages. Installation of Python via conda for the local user does not require administrator permissions. Conda manager allows one to install the necessary Python packages and easily create different environments.

To download an installer for Anaconda3 Python 3.6, please see the tested installations section. The installation procedure is described here. To use Python from Anaconda you need to add a path to the Python executable into your PATH environment variable (the Anaconda installer will suggest it). If you have not agreed to it during the installation procedure, you can do it afterward.

On Linux, append the next line into your bashrc file:
export PATH=/home/your-username/path-to-anaconda3/bin:$PATH
On Windows, append to the Path user environment variable the following paths to your installation of Anaconda (see picture below):
C:\Anaconda3;C:\Anaconda3\usr\bin;C:\Anaconda3\bin;C:\Anaconda3\Scripts;
or if you have it installed only for your user
C:\Users\YourUserName\Anaconda3;C:\Users\YourUserName\Anaconda3\Library\usr\bin;C:\Users\YourUserName\Anaconda3\Library\bin;C:\Users\YourUserName\Anaconda3\Scripts;

On Windows, it might be necessary to restart your system after the installation.

To be able to use Python Scripting in SAMSON you will need the next Python packages installed: jupyter, qtconsole, numpy. You can verify your installation and check whether the necessary packages were installed. These packages should be installed automatically if you installed Python using the Anaconda installer. If they are not installed (which is the case for installation using the Miniconda installer), you can install them via:
conda install numpy jupyter qtconsole

Mac OS

Please, see the list of tested installations for the version to install.

Python can be installed via Homebrew or from python.org.
Warning: The PythonScript Element does not work with Anaconda installation on Mac OS due to a clash between versions of Qt Framework used by SAMSON and Qt Library used by Jupyter QtConsole provided by Anaconda.

Below we will describe the installation procedure via Homebrew.
To install Homebrew, please, follow the instructions on the Homebrew web-site. But, basically, you have to run only the next command:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

To install Python 3 run the next command:
brew install python3

After that, you may be asked to link the executable:
brew link python3

To verify the version of Python run:
python3 --version

The pip3 package manager should be automatically installed with Python 3 by Homebrew.
Optionally, you may want to update pip3:
pip3 install --upgrade pip setuptools wheel

Before installing Jupyter, it is necessary to install some prerequisites, such as SIP:
pip3 install sip

or
brew install sip --with-python3

It is also necessary for Jupyter Qt console to install PyQt5:
pip3 install PyQt5==5.9.2

To be able to use Python Scripting in SAMSON you will need to install the next Python packages: jupyter, qtconsole, numpy.
pip3 install numpy
pip3 install jupyter

[Optional] If you want to use matplotlib package, you may first need to install pkg-config, libpng and freetype if they aren’t installed already.
brew install pkg-config libpng freetype
pip3 install matplotlib

Verify installation

To test the installation, you can try to open the Jupyter Qt Console by executing the next command in the terminal (for Windows: Anaconda terminal):
jupyter qtconsole

Now, you should be able to use Python Scripting in SAMSON. Launch SAMSON, and choose App → General → Python Scriptin or just click on the icon:

If you do not see neither the icon nor Python Scripting in App → General, please, verify if you properly specified the environment variables for Python as described above in this installation guide.

The Python Scripting console should appear:

Comments are closed.