First time here? We are a friendly community of Power Systems Engineers. Check out the FAQ!

Ask Your Question
0

redirect.psse2py error using PSSEv34 and python3.7.3

asked Feb 5 '1

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

1 answer

Sort by » oldest newest most voted
0

answered Feb 5 '1

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"
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.

sugui_ gravatar imagesugui_ (Feb 8 '1)

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_ (Feb 8 '1)

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.
Want to format code in your answer? Here is a one minute demo on Youtube

Add Answer

[hide preview]

Question Tools

1 follower

Stats

Asked: Feb 5 '1

Seen: 1,061 times

Last updated: Feb 05 '21