Python 3.7 64-bit cannot be use with PSSe v.34 which is a 32-bit application. All usable python versions has to be 32-bit. That is cause of the magic number error.
When you install PSSe v.34.7, there are three psspy folders:
psspy27 - to be used with python 2.7
psspy34 - to be used with python 3.4
psspy37 - to be used with python 3.7
To run PSSe from its GUI, edit the PSSe v.34 link icon by right-clicking and edit its "Target" field:
"C:\Program Files (x86)\PTI\PSSE34\PSSBIN\psse34.exe" -pyver 37
To run python scripts outside PSSe GUI, in a command line box (=DOS window), add the PSSE PSSBIN folder path to the PATH environ variable and use the full path for python.exe corresponding to v.37:
c:\..>c:\python37\python <python script>
To run a python script with PSSe 34.7 with python v.3.7, the path to psspy37 have to be added to the sys.path:
psspy37path = r'C:\Program Files (x86)\PTI\PSSE34\PSSPY37'
sys.path.append(psspy37path)
import psspy
To verify the python version and the psspy version, add to your python code:
print('Python ver %s'%sys.version)
print (psspy.psseversion())