Ask Your Question
0

Unable to import psse34/psspy from Anaconda2.7 32bit python interpreter

asked 2019-12-21 13:49:24 -0600

Soumyabrata Talukder gravatar image

updated 2019-12-21 14:11:01 -0600

While I am able to import psse34/psspy from IDLE (the built-in python interpreter of PSSE), I am not able to do so from Anaconda interpreters. I have appended PSSPY34 path to the python system path, and also added PSSBIN to the OS path variable, but no luck. I tried with all different versions of anaconda: 32/64 bit and 2.7/3.7 python. But I am getting the same error for all versions: 'ImportError: Bad magic number in psspy.pyc' in case of importing psspy, and 'ImportError: Bad magic number in pssloc.pyc' in case of importing psse34. Is anyone able to run PSSE34 from Anaconda before?

Code:

(base) C:>python

Python 2.7.16 |Anaconda, Inc.| (default, Mar 14 2019, 15:49:40) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information.

import os

import sys

psse_path = r"C:\Program Files (x86)\PTI\PSSE34\PSSBIN"

os.environ['PATH']=os.environ['PATH']+';'+psse_path

pssepythonpath = r"C:\Program Files (x86)\PTI\PSSE34\PSSPY34"

sys.path.append(pssepythonpath)

import psse34

Traceback (most recent call last):

File "<stdin>", line 1, in <module>

File "C:\Program Files (x86)\PTI\PSSE34\PSSPY34\psse34.py", line 24, in <module> import os, psseloc

ImportError: Bad magic number in C:\Program Files (x86)\PTI\PSSE34\PSSPY34\psseloc.pyc

import psspy

Traceback (most recent call last):

File "<stdin>", line 1, in <module>

ImportError: Bad magic number in C:\Program Files (x86)\PTI\PSSE34\PSSPY34\psspy.pyc

>

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
1

answered 2020-01-07 17:57:19 -0600

jconto gravatar image

Setting up Anaconda to work with PSSe is a little tricky. PSSe v.34 is still a 32-bit application,therefore Anaconda has to be also a 32-bit version (for python 2.7 or python 3.4)

Anaconda install a version of python in its own directory. When running this Anaconda installed python, the path to psspy shall be appended to its sys.path. So in your scenario, above, assuming you open a CMD window or within the IDE Spyder (comes with Anaconda) showing that Anaconda's python v2.7 is running, then to connecto to PSSe v.34:

C:\ProgramData\Anaconda2>python
Python 2.7.15 |Anaconda, Inc.| (default, May  1 2018, 18:37:12) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os,sys
>>> psspypath = r"C:\Program Files (x86)\PTI\PSSE34\PSSPY27"
>>> sys.path.append(psspypath)
>>> import psse34
>>> import psspy
>>> psspy.psseinit(15000)

 PSS(R)E Version 34
 Copyright (c) 1976-2020
 Siemens Industry, Inc.,
 Power Technologies International                            (PTI)
 This program is a confidential  unpublished  work  created  and  first
 licensed in 1976.  It is a trade secret which is the property of  PTI.
 All use,  disclosure,  and/or reproduction not specifically authorized
 by  PTI  is prohibited.   This  program is protected  under  copyright
 laws  of  non-U.S.  countries  and  by  application  of  international
 treaties.  All  Rights  Reserved  Under  The  Copyright  Laws.


           SIEMENS POWER TECHNOLOGIES INTERNATIONAL

      15000 BUS POWER SYSTEM SIMULATOR--PSS(R)E-34.6.0

             INITIATED ON TUE, JAN 07 2020  18:06
0
>>>

Similar declaration can be formed when setting Anaconda with python v.3.4 and PSSe v.34 for python v.3.4

edit flag offensive delete link more
0

answered 2020-01-03 08:01:08 -0600

drsgao gravatar image

Your code here says you are using Python 2.7 to import the psspy for Python 3.4. Of course you would get a bad magic number as a result. You either need to import the psspy for Python 2.7 or use Python 3.4 to import the psspy for Python 3.4. PSSE does not support Python 3.7.

edit flag offensive delete link more

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

3 followers

Stats

Asked: 2019-12-21 13:49:24 -0600

Seen: 2,914 times

Last updated: Jan 07 '20