Ask Your Question
0

Import psse34 and psspy

asked 2024-02-15 23:27:09 -0500

YKC gravatar image

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'
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2024-02-16 10:41:05 -0500

jconto gravatar image

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

edit flag offensive delete link more

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 gravatar imageYKC ( 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 gravatar imagejconto ( 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 gravatar imageYKC ( 2024-02-19 18:39:05 -0500 )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: 2024-02-15 23:27:09 -0500

Seen: 304 times

Last updated: Feb 16