Can't Find Minizinc Driver
Solution 1:
There are two ways to make MiniZinc Python aware of where MiniZinc was installed:
- You can append your
PATH
environment variable with the directory where theminizinc
executable was installed. - You can select a specific driver using the
find_driver
function and then use themake_default
method onDriver
object that is returned.
For either method you first need to find where you have installed the minizinc
executable. If you installed using the AppImage, then you can create a symlink:
$ ln -s MiniZinc<something>.AppImage /my/path/to/minizinc
This symlink will then function as the MiniZinc executable. In the following examples I will use /my/path/to/minizinc
as the location of MiniZinc, but you find where it is on your own computer.
Method 1
Using the first method is usually preferred unless you want to use multiple versions of MiniZinc. If you have a MiniZinc Python script script.py
that you want to execute. You simply first add the executable location to the PATH
environment variable, and then run your script.
$ export PATH=$PATH:/my/path/to$ python script.py
You only have to set the PATH
once per terminal session, so afterwards you can just repeatedly run the second line. If you use MiniZinc often, then it might be a good idea to this export
line to you .bashrc
(or depending on what shell you use a different file).
Method 2
The other method is to edit your MiniZinc Python script. Where you used to have
import minizinc
[SOMETHING]
You would now write
import minizinc
my_driver = minizinc.find_driver("/my/path/to")
my_driver.make_default()
[SOMETHING]
To make sure it found the executable you can even add print(my_driver)
so see which MiniZinc executable it found.
Note that this method will still give you a warning since, at import time, MiniZinc Python cannot find the driver. It also makes your Python code less portable, since someone else might have installed MiniZinc in a different location.
Post a Comment for "Can't Find Minizinc Driver"