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
In some cases your python install might be finding the wrong win32api
library. This can happen when you have multiple python versions installed on your box and python looks at the wrong library (often because of the PATH env)
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'
Here's my environment where MOD works.
No python directories in PATH
env variable.
$ echo %PATH%
I don't like my python stuff in system env variables. You can put it in user env variables if you want to.
I have to set PYTHONHOME for PSSE to work:
$ echo %PYTHONHOME%
c:\python39
Make sure this points to the same location as your registry.
My python version:
$ python
Python 3.9.13 (main, Aug 25 2022, 23:51:50) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Registry points to python 3.9 64bit:
> reg query HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\3.9\InstallPath
HKEY_CURRENT_USER\SOFTWARE\Python\PythonCore\3.9\InstallPath
(Default) REG_SZ c:\Python39\
To test launch I use the command:
"C:\Program Files\PTI\PSSE35\35.5\PSSBIN\psse35.exe" -pyfil "C:\Program Files (x86)\PTI\PSSMODFileBuilder\PSSPY\psspywndmsg.py"
I like to remove the -embed
option for testing. This makes it easier to see PSSE log.
I'm using MOD File Builder 11.3.0.5
I've used this to fix a couple problematic MOD installs. If you see something new, leave some feedback in the comments below.