1

[SOLVED] Cannot load psscommon

When running my code, I get this traceback. This is only on PSSE 34.9.4 and 32 bit Python 3.9.13, using 32 bit Python 2.7.18 and PSSE 34.9.4 works just fine.

PS C:\Users\path> .\run.bat
    Traceback (most recent call last):
        File "C:\Users\path\program.py", line 26, in <module>
            import psspy
        File ".\psspy.py", line 56, in <module>
ImportError: DLL load failed while importing psscommon: The specified module could not be found.

I have done all the importing and path setting with this code.

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

The part that confuses me is that the file psspy.pyc and psscommon.pyd are both in the folder added to the path.

miltonfrey's avatar
37
miltonfrey
asked 2022-10-11 08:37:56 -0500, updated 2022-10-13 11:48:51 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

1

SOLVED

I was able to get it working. All that was missing was import psse34 as well.

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

This solves the DLL import issue. I'm not sure why, but there's the fix.

miltonfrey's avatar
37
miltonfrey
answered 2022-10-13 11:48:31 -0500
edit flag offensive 0 remove flag delete link

Comments

From rev 34 you don’t need to set the path. Just import psse34 and psspy.

perolofl's avatar perolofl (2022-10-13 13:52:24 -0500) edit

That's what I was doing previously when using Python 2.7, but I was no longer able to get it to work in Python 3.9. It can't find psse34 even though 'C:\Program Files (x86)\PTI\PSSE34\PSSPY39' is in PATH variable.

miltonfrey's avatar miltonfrey (2022-10-13 13:58:51 -0500) edit

Thank you, I had the same issue and this solved it!

QuinnP's avatar QuinnP (2023-01-23 21:06:27 -0500) edit
add a comment see more comments

Your Answer

Login/Signup to Answer