I have written a script to perform a number of broadband speed tests using python/tkinter and the speedtest libraries (speedtest/speedtest-cli). The program works as expected when run as a normal python script. I can create an exe file using cx_freeze and it creates everything as per normal. When I run the exe file I get the following traceback…
Traceback (most recent call last):
File
"c:@python@w4itdevlibsite-packagesspeedtest.py",
line 156, in <module>
import_builtin___
ModuleNotFoundError: No module named '__builtin__
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File
"C:@python@w4itdevLibsite-packagescx_Freezeinitscript s_startup__.py", line 141, in run module_init.run(name + "__main__")
File
"C:@python@w4itdevLibsite-packagescx_Freezeinitscript
sconsole.py", line 25, in run
exec(code, main_globals) File "st.py", line 2, in <module>
File "c:@python@w4itdevlibsite-packagesspeedtest.py", line 179, in <module>
_py3_utf8_stdout= _Py3Utf8Output(sys.stdout)
File "c:@python@w4itdevlibsite-packagesspeedtest.py", line 166, in __init__
buf FilelO(f.fileno), 'w')
AttributeError: 'NoneType' object has no attribute 'fileno'
I have grabbed a simpler python script that does a similar job to test whether I had made mistakes with my code. This gave the same results. To keep things simple I have included the simple script as opposed to my original.
from tkinter import *
from speedtest import Speedtest
def update_text():
speed_test = Speedtest()
download = speed_test.download()
upload = speed_test.upload()
download_speed = round(download / (10**6), 2)
upload_speed = round(upload / (10**6), 2)
down_label.config(text= "Download Speed - " + str(download_speed) + "Mbps")
up_label.config(text= "Upload Speed - " + str(upload_speed) + "Mbps")
root = Tk()
root.title("Internet Speed Tracker")
root.geometry('300x300')
button = Button(root, text="Get Speed", width=30, command=update_text)
button.pack()
down_label = Label(root, text="")
down_label.pack()
up_label = Label(root, text="")
up_label.pack()
root.mainloop()
It would appear, though I’m no expert, that its a combination of tkinter/speedtest/cx_freeze and ultimately stdout.
BTW… chatgpt has been going round in circles trying to resolve this.
Julian Wise is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.