I cannot run Pyomo models

996 views
Skip to first unread message

Ayman Afifi

unread,
Feb 18, 2015, 12:58:49 AM2/18/15
to pyomo...@googlegroups.com
Hi, 
Sorry I'm new to Pyomo so this might seem a bit naive. I've installed Pyomo and was able to import it to the shell. However, when I try to call my saved model, it gives an error: 'invalid syntax'. My *.py model file is in my Scripts folder in Python\ArcGIS10.2\Scripts. I followed the instructions for calling a model similar to this one below but I still get the same error. Any help?

pyomo solve --solver=glpk diet1.py diet.dat

Gabriel Hackebeil

unread,
Feb 18, 2015, 1:20:49 AM2/18/15
to pyomo...@googlegroups.com
This probably means you have a syntax error in your model file. This type of error occurs when the Python interpreter doesn’t understand something in your file. It probably doesn’t have anything to do with Pyomo at this point. If you’re not getting any information about where the error occurs you should try executing your model file with the Python interpreter:

python diet1.py

Gabe

--
You received this message because you are subscribed to the Google Groups "Pyomo Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyomo-forum...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ayman Afifi

unread,
Feb 18, 2015, 3:38:32 PM2/18/15
to pyomo...@googlegroups.com
Thanks Gabriel. The command >>>python diet1.py also gives the same error that I see with >>>pyomo diet1.py . I run the abstract model diet1.py script and I get no error on my console. 'diet1.py' is the example script given in the help manual so I'm assuming it should work! 

Any thoughts?

Gabe Hackebeil

unread,
Feb 18, 2015, 3:51:52 PM2/18/15
to pyomo...@googlegroups.com
Can you send the full error message?

Gabe

--

Siirola, John D

unread,
Feb 18, 2015, 4:14:10 PM2/18/15
to pyomo...@googlegroups.com
The problem is that you are trying to run Python (or the Pyomo script) from within the Python interpreter. Both the pyomo script and the examples that Gabe is suggesting are meant to run at the system command prompt. 

John

Jingyi

unread,
May 3, 2016, 12:06:37 PM5/3/16
to Pyomo Forum
If i run in the terminal(ubuntu 14.10):

pyomo solve --solver=glpk diet1.py diet.dat

it returns pyomo: command not found

If I run that in the python after "import pyomo.core"

it returns: invalid syntax

Gabriel Hackebeil

unread,
May 3, 2016, 12:14:20 PM5/3/16
to pyomo...@googlegroups.com
The pyomo command is an executable file located in some directory on your system. If that directory has been added to your PATH environment variable, then you should be able to execute the pyomo command from your terminal. If not, you will need to add it, or provide the full path to the pyomo command (which depends on where Pyomo was installed). For example,

/home/gabe/pyomo/bin/pyomo solve …

Alternatively, you can install Pyomo using the pip command (execute "pip install Pyomo” from the terminal). This will likely cause the pyomo command to be installed into a directory that is already in your PATH.

Gabe
Reply all
Reply to author
Forward
0 new messages