Ask Your Question
0

Change the python version or interpreter on pss/e command prompt

asked 2024-03-15 16:56:09 -0500

JQ gravatar image

Hi,

How can I change the python version or interpreter on pss/e command prompt?

The default version in my pss/e command prompt is 3.10.10, but I need to change it to version 3.9, because my pss\e is installed along with python 3.9.

Thanks, JQ

edit retag flag offensive close merge delete

2 answers

Sort by » oldest newest most voted
0

answered 2024-03-16 10:42:19 -0500

jconto gravatar image

updated 2024-03-17 21:37:12 -0500

Expanding on my answer to the post "How to reload psspy to different PSSE version in same script?", the following setup applies to PSSe v.34.7, a 32-bit application and PSSe v.35.6, a 64-bit application:

I run python scripts for PSSe v34 with python 3.7 within a CMD prompt (=DOS window) by double-clicking on a link named '_dos3437'. This link will run a bat file named 'run3437.bat' as part of its starting process [right-click on the link and select properties, the 'Target' box allows for such full-path bat file name entry, like 'C:\WINDOWS\system32\cmd.exe /K "c:..\documents\code\dos\run3439.bat"'. Check the PSSe installed link "PSS®E 34 Command Prompt" for reference.] The bat file contains any valid DOS command and environ variables defined for the PSSe v34 with python 3.7 environment. Among those, the 'pythonhome' variable is the one that select the right python path for the python version! These environ variables together with other default environ variables defined by the Windows OS can be accessed with the python os.environ function. Type 'set'+ <enter> on the DOS window to get a list of all environ variables.

@rem run3437.bat
@echo OFF
Set PSSEVERSION=34
set PYVER=37
Set PYTHONCODE=%USERPROFILE%\Documents\Code\Python\
Set PYTHONHOME=c:\python%PYVER%\
SET PSSEROOT=%PROGRAMFILES(x86)%\PTI\PSSE%psseversion%
SET PSSEPATH=%PSSEROOT%\PSSBIN\
set PSSPLTPATH=%PSSEROOT%\pssbin\
SET PSSPYPATH=%PSSEROOT%\PSSPY%PYVER%\
SET PATH=%PYTHONHOME%;%PYTHONHOME%SCRIPTs;%PSSEPATH%;%JAVAPATH%;%PATH%
Set INCLUDE=%PSSEROOT%\PSSLIB;%INCLUDE%
echo ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
echo   %USERNAME%                           
echo.                                        
echo   PATHs set for PSS/E-%PSSEVERSION% + python %PYVER%  
echo ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
echo %date% %time%

Similarly, the '_dos3539' link for v.35.6 and python 3.9 will run a 'run3539.bat' while opening:

@rem run3539.bat
@rem psspath35=C:\Program Files\PTI\PSSE35\35.6\PSSBIN\psse35
@rem psspltpath35=C:\Program Files\PTI\PSSE35\35.6\PSSBIN32\pssplt35
@echo OFF
Set PSSEVERSION=35
set MINOR=.6
set PYVER=39
set appdata=
Set PYTHONCODE=C:\Users\jsm20\Documents\Code\Python\
@rem Set PYTHONHOME=C:\ProgramData\Anaconda3_64bit\
Set PYTHONHOME=%LOCALAPPDATA%\Programs\Python\Python%PYVER%\
SET PSSEROOT=C:\Program Files\PTI\PSSE%psseversion%\%psseversion%%MINOR%
SET PSSEPATH=%PSSEROOT%\PSSBIN
set psspltpath=%PSSEROOT%\PSSBIN32\
SET PSSPYPATH=%PSSEROOT%\PSSPY%PYVER%\
SET PATH=%PYTHONHOME%;%PYTHONHOME%SCRIPTs;%pssepath%;%tarapath%;%PYTHONCODE%;%PATH%
Set INCLUDE=%PSSEROOT%\PSSLIB;%INCLUDE%
@rem set CONDA_DLL_SEARCH_MODIFICATION_ENABLE=1
echo ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß
echo   %USERNAME%                           
echo   %PYTHONCODE%                                     
echo   PSS/E-%psseversion%%MINOR% + python %PYVER%   
echo ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ
echo %date% %time%

The following python script can run on either "environment", after opening the corresponding link:

psseversion = int(os.environ['PSSEVERSION'])
exec('import psse%s'%psseversion)
import psspy
psspy.psseinit(0)
'more code...'
if psseversion == 34:          # for code unique to PSSe v34
   'do..'
elif psseversion == 35:
     'do..'

Difference in python sintax versions can be selected with an 'if' on 'PYVER':

pyver = int(os.environ['pyver'])
if pyver == 37:
   'do..'
elif pyver == 39:
     'do..'

All these links ('_dos3437', '_dos3539') are on the Desktop, and copied to the working folder.

edit flag offensive delete link more
0

answered 2024-03-16 06:04:27 -0500

perolofl gravatar image

Try argument -pyver 39.

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

1 follower

Stats

Asked: 2024-03-15 16:56:09 -0500

Seen: 116 times

Last updated: Mar 17