Skip to main content

pssepath - Easy PSSE Python coding

author: whit. (whit.com.au)

pssepath simplifies the code required to setup the Python environment necessary to use the PSSE API. Using pssepath all you have to do is::

    import pssepath
    pssepath.add_pssepath()

    import psspy

Tested and works on:

  • PSSE 32
  • PSSE 33
  • PSSE 34
  • PSSE 35

Supports 32 and 64 bit windows (and provides warnings when using mismatched 64 bit python when PSSE requires 32 bit python).

Using this module makes the PSSE system files available for use while avoiding making modifications to system paths or hardcoding the location of the PSSE system folders. This makes PSSE easy to use.

Without pssepath, you have to do something like this::

    import os
    import 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

Furthermore, by including pssepath with any scripts you distribute, others will be able to use your code without having to edit your code to suit their varying install paths (such as different versions of PSSE).

It can also provide information about which version of Python to use with a particular install of PSSE to avoid ImportError: Bad magic number....

Installation

pip install pssepath

or copy the pssepath code directory (the dir that contains core.py) to your project's root directory.

Usage

pssepath provides 3 methods for setting up the PSSE paths:

  • pssepath.add_pssepath()

    Adds the most recent version of PSSE that works with the currently running version of Python.

  • pssepath.add_pssepath(<version>)

    Adds the requested version of PSSE. Remember that specifying a version number may make your code less portable if you or your colleagues ever use a different version. pssepath.add_pssepath(33)

  • pssepath.select_pssepath()

    Produces a menu of all the PSSE and Python installs on your system, along with the required version of Python.

If you have set up your system to have the PSSE system files on the system path at all times, pssepath will only use these files.

For information about the PSSE versions installed on your system, either:

  • execute the pssepath.py file from windows; or
  • run python -m pssepath.pssepathinfo You may have to specify the python install path: ie. c:\Python25\python -m pssepath.pssepathinfo or py.exe -2.5 -m pssepath.pssepathinfo

This will provide you with a summary similar to the following::

Found the following versions of PSSE installed:

    1. PSSE version 32
        Requires Python 2.5-32bit (Current running Python)
    2. PSSE version XX
        Requires Python 2.X-32bit (Installed)
    3. PSSE version XX
        Requires Python 2.X-32bit

Found the following Python installations:
  2.5-32bit (currently running):
    PythonCore: C:\Python25\
  3.7-64bit:
    PythonCore: C:\Users\dan\AppData\Local\Programs\Python\Python37\

The status next to the Python version indicates the installation status of the required Python for the particular PSSE install.

  • Current running Python

    indicates the Python version used to invoke the script (c:\Python25\python.exe if invoked as c:\Python25\python.exe -m pssepath) is appropriate for that version of PSSE.

  • Installed

    indicates that a Python version different to the one used to invoke the script is required for that PSSE version, but that it is already installed on your system.

<nothing>

The absence of a status means that a different version of Python is required to run that version of PSSE and it is not installed on your system. As Python comes bundled with PSSE, this status is unlikely.

Ensuring you use the correct version of Python for the version of PSSE you are running will avoid seeing ImportError: Bad magic number... ever again.

License

This program is released under the very permissive MIT license. You may freely use it for commercial purposes, without needing to provide modified source.

Read the LICENSE file for more information.

Tips on managing multiple Python versions

I like to use batch files that point to a specific python version. For example::

$ more C:\bin\python25.bat
@C:\Python25\python.exe %*

Where the PATH includes c:\bin. Now you can run python scripts with the command::

python25 myscript.py args

instead of:

c:\Python25\python.exe myscript.py args

Contributers

Discussion about this module was conducted at the Python for PSSE Forum involving the following members:

  • Daniel Hillier
  • JervisW
  • Chip Webber

Improvements or suggestions

Visit the Python for PSSE Forum

See also:

For any other questions about Python and PSSE, feel free to raise them on the Python for PSSE Forum

Metadata

Release files for pssepath 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pssepath 0.3.0
File Size Uploaded
pssepath-0.3.0.tar.gz 15.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pssepath 0.3.0
File Interpreter ABI Platform
pssepath-0.3.0-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 29.5 kB

Release files / pssepath-0.3.0.tar.gz

Download URL pssepath-0.3.0.tar.gz
Size 15.5 kB
Tags Source
SHA-256 checksum
How to use checksums
21b7553c11ae7349b8e06f620cb96a776250a3fd68b243f4e906a0ea65d40ae4
BLAKE2b-256 checksum
How to use checksums
9e6b989597bdbd15bcffb9fdfa6175c238f38207e5933a5275ffc09b3feee59d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.13.0

Release files / pssepath-0.3.0-py2.py3-none-any.whl

Download URL pssepath-0.3.0-py2.py3-none-any.whl
Size 14.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
70eb83204917b618fdde59cffdf674e6e390a6803c7f24362d87655163486145
BLAKE2b-256 checksum
How to use checksums
d8630543b11dab6fc718a948d9813a577daca32f9e64d11e2f4c1655392ebf06
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.13.0

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page