Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hi Daniel,

It looks like Python isn't able to find your psspy.py module.

Python looks for files to import in all of the directories listed in sys.path. If you want to look at the directories that are listed by default - type this into your interpreter:

import sys
print sys.path

The path is just a Python list, which means we can add new directories at the end of it. Assuming that you have installed PSSE in the default location lets add the PSSE directory so Python can find the psspy module:

import os,sys

PSSE_LOCATION = r"C:\Program Files\PTI\PSSE32\PSSBIN"
sys.path.append(PSSE_LOCATION)
os.environ['PATH'] = os.environ['PATH'] + ';' +  PSSE_LOCATION 

import psspy

PSSE itself requires that you add to the PATH environment variable so it can find it's own files. We do that by adding to os.environ['PATH'] with a ';' semi-colon separator.

Make sure you always write that second block of code before you import psspy. Now that you have added the correct directories to your path, you can import psspy from within your Python script like a pro.