Tim
Tim

Reputation: 171

Python doesn't find Pyomo

I'm stumped on why Python won't import pyomo. I can find the directory and see it is installed:

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: [email protected]
License: BSD
Location: /Users/user/anaconda/lib/python2.7/site-packages
Requires: appdirs, PyUtilib, six, ply

And the directory is at the front of my $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',  ... ] 

But I still can't import 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

What am I missing here?

Upvotes: 3

Views: 8499

Answers (3)

MCheng
MCheng

Reputation: 1210

Check if you have pandas installed. If not,

pip install pandas

then

pip install pyomo

this works for me

Upvotes: 0

oakca
oakca

Reputation: 1568

I would uninstall it via pip,

pip uninstall pyomo

and then reinstall it via conda.

conda install -c conda-forge pyomo 

Upvotes: 1

nir0s
nir0s

Reputation: 1181

You need to make sure you're trying to import from the same interpreter you're using when you're running pip show.

When these things happen (and they tend to), it's always good to to try and run which python (assuming you're on linux/osx) to verify that it is the python you're intending to use.

Upvotes: 2

Related Questions