Installation

pyNomo is a python library and thus requires working python installation on the computer. pyNomo stands on the shoulders of (read: requires) the python packages: numpy, scipy and pyx that requires LaTeX-installation. From version > 0.3.0 pynomo is compatible both with python 2 and python 3. Though python2 compatibility will drop out in coming releases.

For editing pyNomo scripts any text browser works but integrated development environment (IDE) for python can speed up developments. Good free IDE alternatives are for example PyCharm community edition and spyder.

Python 2.7.x OSX Installation

Note

Note, python 2 is not anymore supported and these instructions are more for historical reference.

In OSX Macports is an effective tool to manage open-source software. In the following a MacPorts environment is set for Python and pyNomo. sudo runs the commands as super-user and requires it’s password to be given.

First install python 2.7

$ sudo port install python27

One can list available python versions on the system with command

$ sudo port select --list python

Select MacPorts python 2.7

$ sudo port select --set python python27

Install python package index tool (pip)

$ sudo port install py27-pip

and set it active

$ sudo port select --set pip pip27

Now python environment should be correct to be run from /opt/local/Library/.... Now install other required packages.

$ sudo port install py27-numpy
$ sudo port install py27-scipy
$ sudo port install py27-pyx
$ sudo port install py27-six
$ sudo pip install pynomo

Python 3.8 OSX Installation

In OSX Macports is an effective tool to manage open-source software. In the following a MacPorts environment is set for Python and pyNomo. sudo runs the commands as super-user and requires it’s password to be given.

First install python 3.8

$ sudo port install python38

One can list available python versions on the system with command

$ sudo port select --list python

Select MacPorts python 3.8

$ sudo port select --set python3 python38

Install python package index tool (pip)

$ sudo port install py38-pip

and set it active (this sets it system-wide, if you are using also python2, consider twice)

$ port select --set pip pip38

Now python environment should be correct to be run from /opt/local/Library/.... Now install other required packages.

$ sudo port install py38-numpy
$ sudo port install py38-scipy
$ sudo port install texlive
$ sudo port install texlive-fonts-recommended

If you set pip active in whole system, run:

$ sudo pip install six
$ sudo pip install pyx
$ sudo pip install pynomo

If not, check where pip is located and run for example (check your pip path)

$ sudo /opt/local/bin/pip install six
$ sudo /opt/local/bin/pip install pyx
$ sudo /opt/local/bin/pip install pynomo

Python 2.7.x Linux installation

Note

Note, python 2 is not anymore supported and these instructions are more for historical reference.

In Debian Linux distribution and in its derivatives (for example Ubuntu and Raspbian) pynomo can be installed using apt-get with the following commands. sudo runs the commands as super-user and requires it’s password to be given.

$ sudo apt-get -y install python
$ sudo apt-get -y install python-numpy
$ sudo apt-get -y install python-scipy
$ sudo apt-get -y install python-pyx
$ sudo apt-get -y install python-pip
$ pip install pynomo

Python 3 Linux installation

In Debian Linux distribution and in its derivatives (for example Ubuntu and Raspbian) pynomo can be installed using apt-get with the following commands. sudo runs the commands as super-user and requires it’s password to be given.

$ sudo apt-get -y install python3
$ sudo apt-get -y install python3-numpy
$ sudo apt-get -y install python3-scipy
$ sudo apt-get -y install python3-pyx
$ sudo apt-get -y install python3-pip
$ pip3 install pynomo

Python 3.x Windows installation

At the time of writing (9th May 2020) default python version is 3.7.6. Try using python 3.7.x or later.

  1. Download and install Anaconda. This will include python 3.x, and among other python numerical packages scipy and numpy.

  2. Download and install TexLive

install `pyx (python graphics package) by running command

pip install pyx

on Anaconda Powershell prompt. Install `pynomo similarly with command

pip install pynomo

Download examples from Github pynomo, go to `examples directory with Anaconda Powershell. Run command

python GENERATE_ALL.py

and all the examples pdf documents should be generated.

Python 2.7.x Docker installation

Note

Note, python 2 is not anymore supported and these instructions are more for historical reference.

Docker is a platform to create a sandboxed virtualized environments. In the following example Dockerfile a virtualized Ubuntu is created that has pyNomo installed with all requirements:

# python 2.7 Dockerfile for pynomo
FROM debian:stable

# Install required packages:
# python, pyx, pip, numpy, scipy, pynomo and their requirements
RUN apt-get update
RUN apt-get -y upgrade
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install apt-utils
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install python
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install python-pip
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install python-numpy
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install python-scipy
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install python-pyx=0.12.1-11

RUN DEBIAN_FRONTEND=noninteractive pip install pynomo six

# Add /app directory and make it working dir
RUN mkdir -p /app
ADD . /app
WORKDIR /app

CMD ["bash"]

Docker container (environment) my_pynomo_docker is built in the directory /my_directory_path that has the file Dockerfile with command

$ docker build -t my_pynomo_docker .

Once environment is built and my_pynomo_file.py is in directory `/my_directory_path/pdf_py_dir/ one can run

$ docker run -it --mount type=bind,source="$(pwd)"/source,target=/app my_pynomo_docker

that opens terminal in /app directory of container that is mapped to directory “$(pwd)”/source of the host system. Note the command $(pwd) used pwd command to print out current working directory. Inside the container one can run own scripts like:

$ python3 my_script.py

That way a folder is used to share the script file and the generated pdf file between host system and the container (virtualized Linux environment).

Python 3 Docker installation

Docker is a platform to create a sandboxed virtualized environments. In the following example Dockerfile a virtualized Ubuntu is created that has pyNomo installed with all requirements:

FROM python:3.7-slim-buster

# Install required packages
RUN apt-get update && apt-get -y install -y \
    python3 \
    python3-pip \
    texlive-latex-base \
    texlive-fonts-recommended
RUN DEBIAN_FRONTEND=noninteractive pip3 install pyx pynomo numpy scipy six

# Add our python app code to the image
RUN mkdir -p /app
ADD . /app
WORKDIR /app

CMD ["bash"]

# run command on command line for mapping directory ./source in current directory to folder /app in container
#
# docker run -it --mount type=bind,source="$(pwd)"/source,target=/app my_pynomo_docker

Docker container (environment) my_pynomo_docker is built in the directory /my_directory_path that has the file Dockerfile with command

$ docker build -t my_pynomo_docker .

Once environment is built and my_pynomo_file.py is in directory `/my_directory_path/pdf_py_dir/ one can run

$ docker run -it --mount type=bind,source="$(pwd)"/source,target=/app my_pynomo_docker

that opens terminal in /app directory of container that is mapped to directory “$(pwd)”/source of the host system. Note the command $(pwd) used pwd command to print out current working directory. Inside the container one can run own scripts like:

$ python3 my_script.py

That way a folder is used to share the script file and the generated pdf file between host system and the container (virtualized Linux environment).