Ask Your Question
0

No module named psspy with psse33

asked 2017-11-20 08:37:14 -0500

YI-WEI gravatar image

updated 2017-11-20 08:38:32 -0500

CODE:

import os,sys

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


I try to use python2.7 to connect psse , but it show ImportError: No module named psspy,please give me help ,thx! ps: I already have download win32com

edit retag flag offensive close merge delete

2 answers

Sort by » oldest newest most voted
0

answered 2017-12-13 11:42:31 -0500

nelak gravatar image

Does this work?

def init_psse(self, vsn=32):
    """
    Inits PSSE to version of parent service.
    """
    # PSSE initialization routine.
    self.PSSE_VERSION == 33
    if self.PSSE_VERSION == 32:
        # this loops takes into account both the 32 and 64 bit registries, fixing an issue, where trying to run python code through certain IDEs wouldn't work.
        try:
            pssepath, regtype = _winreg.QueryValueEx(
                _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\PTI\\PSS\xaeE 32\\Product Paths", 0,
                                _winreg.KEY_READ), "PsseInstallPath")
        except WindowsError:
            pssepath, regtype = _winreg.QueryValueEx(
                _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\\Wow6432Node\\PTI\\PSS\xaeE 32\\Product Paths", 0,
                                _winreg.KEY_READ), "PsseInstallPath")
    elif self.PSSE_VERSION == 33:
        try:
            pssepath, regtype = _winreg.QueryValueEx(
                _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\PTI\\PSSE 33\\Product Paths", 0, _winreg.KEY_READ),
                "PsseInstallPath")
        except WindowsError:
            pssepath, regtype = _winreg.QueryValueEx(
                _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\\Wow6432Node\\PTI\\PSSE 33\\Product Paths", 0,
                                _winreg.KEY_READ), "PsseInstallPath")

    sys.path.append(os.path.join(pssepath, 'PSSBIN'))
    sys.path.append(os.path.join(pssepath, 'PSSLIB'))
    os.environ['PATH'] += ';' + os.path.join(pssepath, 'PSSBIN')
    os.environ['PATH'] += ';' + os.path.join(pssepath, 'PSSLIB')

    if "PTI\PSSE" not in pssepath:
        self.log("ERROR: Cannot find PSS(R)E Version %i." % self.PSSE_VERSION, 'error')
        sys.exit()

    import psspy
    import redirect
edit flag offensive delete link more
0

answered 2017-11-20 20:58:46 -0500

jconto gravatar image

The following code works in v.33.10:

import os,sys
psseversion = 33
if psseversion== 34 or psseversion== 33:
   exec('import psse%s'%psseversion)
else:
   pssepath = r"C:\Program Files (x86)\PTI\PSSE32\PSSBIN"
   if pssepath not in sys.path:
      sys.path.append(pssepath)
edit flag offensive delete link more

Comments

Hi,I try this code and show the message: File "C:/Users/S0131/Desktop/PYTHON-PSSE/PSSE-connect.py", line 9, in <module> exec('import psse%s'%psseversion) File "<string>", line 1, in <module> ImportError: No module named psse33 /********************************************** How to modify?

YI-WEI gravatar imageYI-WEI ( 2017-11-28 09:21:53 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

[hide preview]

Question Tools

1 follower

Stats

Asked: 2017-11-20 08:37:14 -0500

Seen: 1,547 times

Last updated: Dec 13 '17