0

redirect.psse2py error using PSSEv34 and python3.7.3

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\user1\Desktop\V34_test\test.py", line 8, in <module>
    redirect.psse2py()
  File ".\redirect.py", line 147, in psse2py
redirect.RedirectError: Python currently sending output to Psse
Kevin Chuang's avatar
15
Kevin Chuang
asked 2021-02-04 19:23:47 -0500, updated 2025-08-25 00:26:00 -0500
edit flag offensive 0 remove flag close merge delete

Comments

You can use the following code: <1 line> try: redirect.psse2py <2 line> except: pass

jconto's avatar jconto (2025-09-14 18:37:23 -0500) edit
add a comment see more comments

1 Answer

0

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"
jconto's avatar
2.9k
jconto
answered 2021-02-05 09:49:24 -0500
edit flag offensive 0 remove flag delete link

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.

Kevin Chuang's avatar Kevin Chuang (2021-02-07 19:00:50 -0500) 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.

Kevin Chuang's avatar Kevin Chuang (2021-02-07 19:12:17 -0500) edit
add a comment see more comments

Your Answer

Login/Signup to Answer