我很困惑为什么 Python 不会导入 pyomo。我可以找到目录并看到它已安装:
234:pyomo user$ pip show pyomo
Name: Pyomo
Version: 5.1.1
Summary: Pyomo: Python Optimization Modeling Objects
Home-page: http://pyomo.org
Author: William E. Hart
Author-email: wehart@sandia.gov
License: BSD
Location: /Users/user/anaconda/lib/python2.7/site-packages
Requires: appdirs, PyUtilib, six, ply
该目录位于我的 $PYTHONPATH 的前面:
>>> import sys; print sys.path
['', '/Users/user/anaconda/lib/python2.7/site-packages/pyomo', '/Users/user/anaconda/lib/python2.7/site-packages', '/Users/user/anaconda/pkgs', '/Users/user/.local/lib/python2.7/site-packages', '/usr/local/lib/python2.7/site-packages', ... ]
但我仍然无法导入 pyomo:
>>> import pyomo.environ
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pyomo.environ
>>> from pyomo.environ import *
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named pyomo.environ
我在这里想念什么?