Before you can install pyCPA, you must set up Python (Prerequisites). If you already have a Python installation, you may directly proceed with Quickstart. Alternatively, if you want to modify the pyCPA code, please consult For Developers.
A brief introduction in how to test your installation is provided in Using pyCPA.
First of all, you need a basic Python (2.7 or 3.x) environment.
As a Linux user, you most probably have Python already installed.
On Windows, we recommend to use Python(x,y), which includes a comprehensive set of scientific Python libraries and tools as well as related documentation.
Python(x,y) comes with several interactive consoles (based on IPython), editors and applications.
For your first hands-on experience, we recommend using
Spyder as an IDE.
You can also run a command prompt via the Python(x,y) icon on the Desktop and choosing
IPython (sh) as an interactive console.
The easiest way to install pyCPA is by using pip. For a system-wide installation of the current pyCPA version, you simply run the following command:
$ pip install https://github.com/IDA-TUBS/pycpa/archive/master.zip
Alternatively, e.g. if you do not have admin privileges, you can install pyCPA for the current user:
$ pip install --user https://github.com/IDA-TUBS/pycpa/archive/master.zip
pyCPA has the following dependencies:
- Required Python packages: setuptools, argparse, pygraphviz, matplotlib
- Optional Python packages: numpy, simpy, xlrd
Before proceeding, you might want to check the status of your Python installation, i.e. what version is installed (if at all) and what Python packages are already available, using the following commands:
$ python --version $ pydoc modules
For downloading the pyCPA source code, you simply create a clone from the git git repository, e.g. by running the following command:
$ git clone https://github.com/IDA-TUBS/pycpa/
From within the pyCPA repository, execute the following command to install pyCPA in editable mode (i.e. changes to the source code do not require re-installation to be effective):
$ pip install --user -e .
Testing and using pyCPA¶
Congratulations, you have installed pyCPA!
In order to test pyCPA, you may want to run the examples which are provided with the distribution.
The quickest way to do this is to run the following on the command prompt (e.g.
IPython (sh) on Windows):
$ python /path/to/pycpa/examples/spp_test.py
If you want to know what this examples does and how it works checkout the Static Priority Preemtive Example.
Depending on your personal preferences, you may also use an IDE of which we give a more detailed account in the following sections.
Using an IDE: Spyder (Windows)¶
Spyder is installed with Python(x,y).
Simply open one of the example files (e.g. spp_test.py) and click the
Using an IDE: PyDev¶
You may also use Eclipse with PyDev as IDE, which can be installed by the following steps:
- Make sure that you have installed Python BEFORE you install Eclipse.
- Download from http://www.eclipse.org/downloads/eclipse-packages/ the current Eclipse release for Windows 32 bit (!). Extract the zip-file, execute
eclipse.exeand follow the installation instructions.
- Open Eclipse and specify a workspace. If you open a workspace for the first time, you will have to close the Welcome tab, before proceeding to your workspace.
- Select the menu item
Help –> Install New Software, search for the site http://pydev.org/updates. Select and install the item “PyDev” which will be displayed in the list of available software.
Now, you can set up a pyCPA project as follows:
- Open the PyDev-Perspective by selecting in the main menu
Window -> Open Perspective -> Other -> PyDev
- Select in the main menu
File -> New -> PyDev Project.
- In the PyDev-Project Window specify a project name; the project will be saved to your workspace unless specified otherwise.
- Choose the project type “Python” and select the 2.7 interpreter version.
- Click on “Please configure an interpreter before proceeding”.
Manual Configin the pop-up window.
- In the settings for the Python interpreter click
New…and specify an interpreter name, e.g. Python27, and the path to the interpreter executable (e.g.
C:\myPathToPython\python.exe). In the appearing pop-up window select all options.
- In the tab
New Folderand specify the path to the pyCPA-folder (e.g.
- Close the preferences window by clicking ok.
- Back in the PyDev-Project Window, click
add project directory to PYTHONPATHand then the button
- You may now add a Python file to your project (right-click on your project in the PyDev Package Explorer -> New… -> File) and write a Python program (e.g. test.py) which uses pyCPA.
- To run test.py, right-click on
Run as -> Python Run. If you want to modify your run settings in order to e.g. specify arguments, select
Run as -> Run Configurationsand adapt the settings as needed before clicking
Runin the Run Configurations Window.
- You may also try out the examples which are provided with pyCPA such as the Static Priority Preemtive Example.