Ask Your Question
0

redirect.psse2py error using PSSEv34 and python3.7.3

asked 2021-02-04 19:23:47 -0600

sugui_ gravatar image

Hi everyone, I want to run .py file in PSSE, but I have some problem. Here's the code.

import time, socket, sys, os
sys.path.insert(0, 'C:\Program Files (x86)\PTI\PSSE34\PSSBIN')
os.environ['PATH'] = 'C:\Program Files (x86)\PTI\PSSE34\PSSBIN' + ';' + os.environ['PATH']
import psspy, redirect, pssarrays
redirect.psse2py()

Here's the error message. Could someone tell me why redirect.psse2py() not work? thanks.

Traceback (most recent call last):
  File "C:\Users\u027692\Desktop\V34_test\sa_1.05_V34.py", line 8, in <module>
    redirect.psse2py()
  File ".\redirect.py", line 147, in psse2py
redirect.RedirectError: Python currently sending output to Psse
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2021-02-05 09:49:24 -0600

jconto gravatar image

In the PSSe GUI, the "output bar" receives all messages and prints by default. In a python script, since there is no external CMD prompt window open (=DOS window), there is no need to redirect to ''PSSE2PY', and actually, it is an 'PSSe error' to try to do that.

Also, only when PSSe GUI starts, the path needed to access psspy or other PSSe modules is set internally, hence, no need to define it again in the syspath variable. The module 'psspy' is loaded and 'psseinit()' is executed internally.

Run the code below in the PSSe GUI :

# hello.py
print('Welcome to hello.py')
import sys, os
import time
import socket
#sys.path.insert(0, 'C:\Program Files (x86)\PTI\PSSE34\PSSBIN')
#os.environ['PATH'] = 'C:\Program Files (x86)\PTI\PSSE34\PSSBIN' + ';' + os.environ['PATH']
#import psspy
#import redirect
import pssarrays
#redirect.psse2py()

psspy.case(r"C:\Program Files (x86)\PTI\PSSE33\EXAMPLE\savnw.sav"
edit flag offensive delete link more

Comments

I use this .py to do ACCC, and I don't want the progress print at output bar because I have a lot of contingencies. It's work in v32, but not in v34. Thus, I'm seeking what makes it go wrong. Thanks for your answer. I learn a lot.

sugui_ gravatar imagesugui_ ( 2021-02-07 19:00:50 -0600 )edit

I use "progress_output" function to solve it. I first set islct=6 and then set islct=1 to print ending message.Thanks again.

sugui_ gravatar imagesugui_ ( 2021-02-07 19:12:17 -0600 )edit

Your Answer

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

Add Answer

[hide preview]

Question Tools

1 follower

Stats

Asked: 2021-02-04 19:23:47 -0600

Seen: 1,006 times

Last updated: Feb 05 '21