MOD File Builder often has trouble connecting to the PSSE API if the environment on your machine isn't exactly like PSSE/MOD expects.
This document show some common issues with MOD File Builder install and how to fix them.
If you can't get PSSE to open without MOD, you need to debug that first. Here are some PSSE Debug Notes
The MOD FIle Builder has two parts:
- The GUI (Graphical User Interface)
- The PSSE Bridge
graph LR
A[MOD GUI] --- B[PSSE Bridge]
When you start MOD file buider it starts both of these parts seperately. The PSSE bridge often fails to startup correctly.
Under the hood, MOD starts the PSSE bridge with a command like this:
"C:\Program Files\PTI\PSSE35\35.4\PSSBIN\psse35.exe" -embed -pyfil "C:\Program Files (x86)\PTI\PSSMODFileBuilder\PSSPY\psspywndmsg.py"
If the startup fails, you see an error messge related to win32api
in PSSE this in PSSE:
C:\Program Files (x86)\PTI\PSSMODFileBuilder appended to sys.path
Traceback (most recent call last):
File "C:\Program Files (x86)\PTI\PSSMODFileBuilder\PSSPY\psspywndmsg.py", line 25, in <module>
import win32api
ImportError: DLL load failed while importing win32api: %1 is not a valid Win32 application.
You may also see an error about DLL not found
If you get an error about DLL's not found, you probably have a broken pywin32
installation. This library often has trouble
with installs even without PSSE/MOD. See this StackOverflow question for all the problems people have with this package.
The following instructions need to be run in a cmd.exe
terminal and assume you have the proper python in your PATH
.
You might need to run a command like this to setup your PATH
first:
SET PATH=c:\Python39;c:\Python39\scripts;%PATH%
In many cases, you can just reinstall the pywin32
package to fix your problems:
pip install --upgrade pywin32
To sanity check the installation, try to import the module in your system python:
> python -c "import win32api;print(win32api.__file__)"
c:\Anaconda3\lib\site-packages\win32\win32api.pyd
To fix this issue we need to make sure the bridge is using the proper version of win32api
.
To fix this, we force the bridge to start with a known good environment.
Instructions:
- Start the PSSE bridge manually with the below script (may require tweaks)
- Start the MOD File Builder normally
Start the PSSE bridge manually like this:
SET PYTHONHOME=c:\Python39
"C:\Program Files (x86)\PTI\PSSE35\35.4\PSSBIN\psse35.exe" -pyver 39 -embed -gohome -pyfil "C:\Program Files (x86)\PTI\PSSMODFileBuilder\PSSPY\psspywndmsg.py"
ℹ️
psspywndmsg.py
fiddles with the path and addsC:\Program Files (x86)\PTI\PSSMODFileBuilder
to the PATH. This may be why the wrong version ofwin32api
is found.
To fix an error like this, install pywin32
using the pip instructions in this document:
Traceback (most recent call last):
File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'win32api'
I've used this to fix a couple problematic MOD installs. If you see something new, leave some feedback in the comments below.