How to run psse from tkinter

asked 2021-03-17 06:34:45 -0500

msmirza gravatar image

Hi, I'm hoping someone can help me solve this problem. My python script is working fine in Spyder IDE. But when I convert it to .exe using pyinstaller I get an error that psse dongle is missing. Thus PSSE does not even initialize. Below is the code I'm using. Really appreciate if someone could help me out.

import Tkinter as tk
import Tkconstants, tkFileDialog, tkMessageBox
import os
import sys
import datetime
PSSE_PATH = r"C:\Program Files (x86)\PTI\PSSE33\PSSBIN"
os.environ['PATH'] += ';' + PSSE_PATH
sys.path.append(PSSE_PATH)
import psspy
import excelpy
import redirect
redirect.psse2py()
apps = []

def update_case():
 k = apps[0]
 case_file = k.encode("utf-8")
 excelfile= r"E_PY.xlsx"
 E_PY = excelpy.workbook(excelfile, 'test', mode ='r')
 time_data = E_PY.get_cell((2,2), sheet="E_GEN")
 E_PY.close()   
 psspy.psseinit()
 psspy.case(case_file)
 execfile('mirza2.py')
 file_name_lb.config(bg ="green")
 file_name_lb["text"] = "PSSE Case File Created" 

root = tk.Tk()
#title of program
root.title("PSSE Python Project v1.0")
root.configure(bg="black")
root.iconbitmap('ng1.ico')
# save new psse base case
save_case = tk.Button(root,text="5- Update PSSE Case", padx=8, pady=5, command=update_case)
save_case.grid(row=1, column=0, sticky = "w")
root.mainloop()
edit retag flag offensive close merge delete

Comments

In the past, I've tried wrapping psspy into an .exe as an experiment without success. I imagine for intellectual property reasons, it's going to be very difficult. What's the intent of wrapping it in an exe? Perhaps a halfway solution could be to make the GUI without of psspy and call a py process

likethevegetable gravatar imagelikethevegetable ( 2021-03-19 06:55:51 -0500 )edit

to protect the source code and second everyone would not have to install anaconda software to run it. That would give them access to the script.

msmirza gravatar imagemsmirza ( 2021-03-21 00:46:39 -0500 )edit

Just an FYI, if you're using PyInstaller, I recommend avoiding using an Anaconda installation, the resulting exe will be far too large and you're likely more error-prone. Think about it from PTI's perspective: they wouldn't want you distributing it so others could use without a license.

likethevegetable gravatar imagelikethevegetable ( 2021-03-23 15:03:59 -0500 )edit

Size is 120MB of the .exe file. To protect the code of how I have taken into consideration in setting generation and load allocation. They all would need psse license on their computer. The problem is after an exe is created I get dongle is missing error. But runs fine in Spyder IDE as script.

msmirza gravatar imagemsmirza ( 2021-03-24 05:07:30 -0500 )edit

Since the user will have PSSE installed, they would also have python--perhaps an easier solution would be to make a portable virtual environment (with tkinter and whatever else you need) and share your proprietary scripts as .pyc file.

likethevegetable gravatar imagelikethevegetable ( 2021-03-24 08:47:21 -0500 )edit