pip says minizinc
is already installed, but when I try to call it in code, it gives me error saying it is not installed.
(backend) bash-3.2$ python
Python 3.8.3 (default, Jul 2 2020, 11:26:31)
[Clang 10.0.0 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from minizinc import Instance, Model, Solver
/Users/miranda/.local/share/virtualenvs/backend-BjqhdW2P/lib/python3.8/site-packages/minizinc/__init__.py:25: RuntimeWarning: MiniZinc was not found on the system. No default driver could be initialised.
warnings.warn(
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name 'Instance' from 'minizinc' (/Users/miranda/.local/share/virtualenvs/backend-BjqhdW2P/lib/python3.8/site-packages/minizinc/__init__.py)
>>> exit()
(backend) bash-3.2$ pip install minizinc
Requirement already satisfied: minizinc in /Users/miranda/.local/share/virtualenvs/backend-BjqhdW2P/lib/python3.8/site-packages (0.4.2)
(backend) bash-3.2$ python3 -m pip install minizinc
Requirement already satisfied: minizinc in /Users/miranda/.local/share/virtualenvs/backend-BjqhdW2P/lib/python3.8/site-packages (0.4.2)
(backend) bash-3.2$ python -m pip install minizinc
Requirement already satisfied: minizinc in /Users/miranda/.local/share/virtualenvs/backend-BjqhdW2P/lib/python3.8/site-packages (0.4.2)
As explained on MiniZinc Python's "Getting Started" page. MiniZinc Python is not the same as MiniZinc itself, it is merely a connection from Python to MiniZinc.
That means that before you can use MiniZinc Python, you also have to install the MiniZinc bundle. This is what the error is trying to tell you. The bundle can be found on the MiniZinc website.
Note that after the installation MiniZinc Python will look on your computer for the minizinc
executable whenever you import minizinc
in Python. If you haven't installed MiniZinc in the usual location, then you might need to append your PATH
environment variable with the directory in which the minizinc
to make it work.