安装了 minizinc 但 python 认为没有

minizinc installed but python think not

pip 说 minizinc 已经安装,但是当我尝试在代码中调用它时,它给我错误说它没有安装。

(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)

如 MiniZinc Python 的 "Getting Started" 页面所述。 MiniZinc Python 与 MiniZinc 本身不同,它只是从 Python 到 MiniZinc.

的连接

这意味着在您可以使用 MiniZinc Python 之前,您还必须安装 MiniZinc 包。这就是错误试图告诉您的内容。该捆绑包可以在 MiniZinc website.

上找到

请注意,安装 MiniZinc Python 后,只要您 import minizinc 在 Python 中,就会在您的计算机上查找 minizinc 可执行文件。如果您没有在通常的位置安装 MiniZinc,那么您可能需要将 PATH 环境变量附加到 minizinc 所在的目录以使其正常工作。