Ask Your Question
1

Get exact execution string?

asked 2020-01-17 12:37:08 -0600

ibrewster gravatar image

updated 2020-01-17 15:09:28 -0600

Is there a way to get the exact execution string/environment that Wing uses when launching a script? I have a Python/PySide2/matplotlib application set up in a venv that looks correct when I run it from within wing, but if I run it directly from the command line, the font sizes in my plots are all huge. Apparently Wing is doing something right to make it work, but I don't know what.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2020-01-17 13:16:50 -0600

I suspect the difference is in the environment and you probably want to examine the contents of os.environ either by using the Debug Console or adding prints to your code. There isn't a way to show the command line used by Wing but examining sys.executable and sys.argv should allow you to reconstruct it.

edit flag offensive delete link more

Comments

Thanks. os.environ seems to be the same other than some additional wing-specific entries on the wing side (such as WINGDB_SPAWNCOOKIE and WINGDB_WINGHOME). sys.executable is exactly as expected when run directly - the python I called it with. On the wing side, it is '/Applications/WingPro.app/Contents/Resources/wingdb’, which doesn’t help much.

A bit more digging shows me that the crucial difference is that, when run through WingIDE, Matplotlib selects the MacOSX backend, while when run directly it selects the Qt5Agg backend. Still doesn't tell me what wing is doing right and I am doing wrong, but at least it's a pointer in the right direction.

ibrewster gravatar imageibrewster ( 2020-01-17 13:44:08 -0600 )edit

Is sys.executable the same in both cases? Wing may be running a different Python installation. I'm not sure how matplotlib decides on the default and in fact was under the impression it would always be MacOSX on macOS, but apparently not. You can explicitly set it with matplotlib.use('MacOSX') after importing matplotlib and before doing anything else.

Wingware Support gravatar imageWingware Support ( 2020-01-17 14:01:27 -0600 )edit

As I stated, no, sys.executable is NOT the same. To quote: "sys.executable is exactly as expected when run directly - the python I called it with. On the wing side, it is '/Applications/WingPro.app/Contents/Resources/wingdb’"

So far Matplotlib.use('MacOSX') is not working, I'm currently debugging that. Thankfully Wing makes that easy by being able to simply import wingdbstub when I run the program externally, so thanks for that!

ibrewster gravatar imageibrewster ( 2020-01-17 14:05:30 -0600 )edit

Oh, sorry, I missed that part somehow. In this case, wingdb will start the Python named in the environment variable WINGDB_PYTHON. The reason sys.executable is set to that is so Wing can debug child processes. You can turn that off with the Debugger > Processes > Replace sys.executable preference although I would do that only for testing and not leave it off because it can break some things (on Windows it entirely breaks child process debugging; on macOS and Linux it's not a critical).

Wingware Support gravatar imageWingware Support ( 2020-01-17 14:10:08 -0600 )edit

Just as a further follow-up, apparently it IS getting set properly when I call Matplotlib.use(), but then it gets changed when I call import Matplotlib.pyplot

ibrewster gravatar imageibrewster ( 2020-01-17 14:20:44 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-01-17 12:37:08 -0600

Seen: 118 times

Last updated: Jan 17