jrglez
jrglez

Reputation: 238

Python executable with pyinstaller and Pmw

I am trying to create an executable in windows using pyinstaller, but I get an error when running the executable if I import Pmw.

I am using the following code to create a sample GUI

import tkinter as tk
from tkinter import ttk
import Pmw

class Test():
    def __init__(self):
        self.mainwindow = tk.Tk()
        self.mainwindow.title("Main Window")
        self.mainwindow.geometry("600x300")
        self.mainwindow.configure(background='light sea green')
        self.textInfo = tk.Text(self.mainwindow, width=60, height=30)
        self.textInfo.pack(side=tk.TOP)
        
        self.labelWelcome = ttk.Label(self.mainwindow, text="Welcome to the Ribadesella Guest House Platform!")
        self.labelWelcome.place(x = 160, y = 80, width = 280, height = 30)

        
        self.buttonHello = ttk.Button(self.mainwindow, text="Hello", command=self.hello) 
        self.textHello = tk.Text(self.mainwindow)
                                    
        self.buttonHello.place(x = 80, y = 200, width = 150, height = 35)
        self.textHello.place(x = 230, y = 200, width = 150, height = 35)

        
        self.mainwindow.mainloop()
    
    def hello(self):
        self.textHello.insert(tk.END,'Hello world')


start = Test()

It compiles and runs well if I omit the line import Pmw, but if I include it, I get the error:

Traceback (most recent call last):
  File "test.py", line 10, in <module>
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "c:\anaconda3\lib\site-packages\Pmw\__init__.py", line 34, in <module>
    _loader = 'Pmw.' + _instdirs[0] + '.lib.PmwLoader'
IndexError: list index out of range

I understand it has something to do with the package lazy importer, but I have no clue how to fix it (or what a lazy importer is, for that matter)

A few more details bellow:

Upvotes: 0

Views: 393

Answers (1)

jrglez
jrglez

Reputation: 238

There is a working solution here. The link in the answer is not working (that's the reason why I posted this question), but there is a working one in the comments of said answer.

Upvotes: 0

Related Questions