I have built several successful codes for MPC using Gekko python in offline mode. However, i still want to remove the blinking of the command window while running the program. Any suggestions ? Thank you.
Asked
Active
Viewed 158 times
4
-
1I'll take a look at some of these suggestions: https://stackoverflow.com/questions/7006238/how-do-i-hide-the-console-when-i-use-os-system-or-subprocess-call – John Hedengren Nov 08 '19 at 03:24
-
I was going to ask this question too. The flashing screen doesn't happen when in an IPython notebook with local solve. The new version of gekko resolves the problem. – TexasEngineer Nov 22 '19 at 16:16
-
Exactly, updating gekko solves the problem as explained by Professor John. – Mohamad Ibrahim Nov 23 '19 at 18:07
1 Answers
0
New Version Edit
The latest version of Python Gekko (v0.2.4) removes the command window pop-up when solving locally on Windows. To upgrade gekko to the latest version use:
pip install gekko --upgrade
or if using an IPython notebook run the cell:
!pip install gekko --upgrade
The additional argument --user
may be required if the Python install requires administrative privilege.
Original Response
When using remote=False
, the new command window is removed with the addition of shell=True
to the subprocess call.
app = subprocess.Popen([apm_exe, self._model_name], stdout=subprocess.PIPE, \
stderr=subprocess.PIPE, cwd = self._path, bufsize=4096, \
env = {"PATH" : self._path }, universal_newlines=True, shell=True)
I'll implement this in the next Gekko release or you can modify your gekko.py
file in Python\Lib\site-packages\gekko
around line 1880.

John Hedengren
- 12,068
- 1
- 21
- 25
-
Dear Professor, thank you for your comments. I added what you recommended after m = GEKKO(remote=False) and I imported subprocess. However, once I ran the code, an error saying " apm_exe is not defined" has appeared. – Mohamad Ibrahim Nov 08 '19 at 09:33
-
You can't add it to your script. You need to modify it in gekko.py in your Python installation folder `Lib\site-packages\gekko` or just wait for the next version of Gekko to be released and upgrade with `pip install gekko --upgrade` at a command terminal. – John Hedengren Nov 08 '19 at 15:48
-
The new version of Gekko is now available. You can upgrade with `pip install gekko --upgrade` or `pip install gekko --user --upgrade` (if you don't have admin privilege). – John Hedengren Nov 10 '19 at 13:11