0

Import psse34 and psspy

Hello everyone,

I want to use python in VS code to control PSS/E, but I can not import psse34 and psspy in python. Could anyone please help me solve the problem? I already try most of the python coding from this forum.

The following is my python code:

> import os, sys
> PSSE_LOCATION = r"C:\\Program Files(x86)\\PTI\\PSSE34\\PSSPY27"
> sys.path.append(PSSE_LOCATION)
> os.environ['PATH'] = os.environ['PATH'] + ';' + PSSE_LOCATION 
> 
> import psse34
> import psspy

Then, VScode gave the error as:

> import psse34   
> File "C:\\Program Files(x86)\\PTI\\PSSE34\\PSSPY27\psse34.py", line 21, in "module"
> import os, psseloc 
> ImportError: bad magic number in 'psseloc': b'\x03\xf3\r\n'
YKC's avatar
50
YKC
asked 2024-02-15 23:27:09 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

0

The above code runs ok in VSC!

In VSC, load your code and then under 'View', select 'Terminal'. Now in the lower right corner, check that 'python' and the right python version (like 2.7.18 32 bit) is being displayed. If not, click on the python version and enter the path to the python 2.7 32-bit in your pc. Run the script using the play button on the top right corner (do not use a debugger).

jconto's avatar
2.9k
jconto
answered 2024-02-16 10:41:05 -0500
edit flag offensive 0 remove flag delete link

Comments

Thank you for answering the question, it seem can run now. However, I met another problem. I would like to change the generation of each machine, and I use "psspy.machine_chng_2" to do it, then, VSC give an error that "_i", "_f" are not defined. Do you also have any suggestion to solve this issue?

YKC's avatar YKC (2024-02-16 19:44:33 -0500) edit

After psspy is loaded, add the following code lines: _i = psspy.getdefaultint(); _f = psspy.getdefaultreal(); _s = psspy.getdefaultchar()

jconto's avatar jconto (2024-02-19 13:46:57 -0500) edit

I am really appreciate your help, it does solve the problem!!! Thank you for your time to answer these questions.

YKC's avatar YKC (2024-02-19 18:39:05 -0500) edit
add a comment see more comments

Your Answer

Login/Signup to Answer