Installation
0) Zero Installation from Google Colab
This is an immediate solution for using PyCSP3, with no installation required (you are ready to work in exactly 2 minutes). What you have to do is:
- build a new notebook on Google colab
- insert a first code cell for being able to use PyCSP3 in your notebook:
pip install pycsp3
- test a very basic model by inserting in a second code cell something like:
from pycsp3 import * x = VarArray(size=5, dom=range(5)) satisfy( AllDifferent(x) ) if solve() is SAT: print(values(x))
Here, we have an array with 5 variables, we enforce them to be all different, and we display the first solution found by the underlying solver. Just execute these cell codes on Colab. That’s it. However, note that for intensive use, it is better to install PyCSP3 on your computer; see next section.
1) Installation from PyPi
This is the easiest way of installing PySCP3.
Note that you need first Python 3.10 (or later) to be installed. You can do it, for example, from python.org
Installing PyCSP3 (Linux)
Check if ‘pip3’ is installed. If it is not the case, execute:
sudo apt install python3-pip
Then, install PyCSP3 with the command ‘pip3’:
sudo pip3 install pycsp3
For using the -solve or -solver options, you need to have Java (at least, version 11) installed:
sudo apt-get install openjdk-11-jdk
Installing PyCSP3 (Mac OS)
If Python 3 is installed on your system, the command ‘pip3’ should already be present.
Install PyCSP3 with the command ‘pip3’:
sudo pip3 install pycsp3
For using the -solve or -solver options, you need to have Java (at least, version 11) installed.
Installing PyCSP3 (Windows)
You may need to upgrade ‘pip’. Open the console and type:
python -m pip install --upgrade pip
Then, for installing PyCSP3, type:
python -m pip install pycsp3
For using the -solve or -solver options, you need to install (at least) Java version 11:
https://www.oracle.com/java/technologies/javase-downloads.html
And add in the PATH the java command, for example, temporally, with the command:
set path=%path%;C:/Program Files/Java/jdk-14.0.1/bin/
You can check the java command by typing in your console:
java --version
Updating the Version of PyCSP3 (for PyPi)
For updating your version of PyCSP3, simply execute:
For linux/Mac:
sudo pip3 install --upgrade pycsp3
For Windows:
python -m pip install --upgrade pycsp3
2) Installation (alternative) by Cloning from GitHub
An alternative to Pypi is to clone the code from GitHub. Here is an illustration for MAC OS. We assume that Python 3 is installed (otherwise, type port install python38
for example), and consequently ‘pip3’ is also installed. In a console, type:
git clone https://github.com/xcsp3team/pycsp3.git
pip3 install lxml
You may need to update the environment variable ‘PYTHONPATH’, by typing for example:
export PYTHONPATH=$PYTHONPATH:.