Reputation: 1
When I open idle through the terminal, idle opens fine but as soon as I try to scroll over the idle window or make any slightly quick movements of the idle window, it immediately crashes with error:
Traceback (most recent call last):
File "/usr/local/bin/idle3", line 5, in <module>
main()
File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/idlelib/pyshell.py", line 1552, in main
root.mainloop()
File "/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/tkinter/__init__.py", line 1283, in mainloop
self.tk.mainloop(n)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
I have tried the command brew reinstall python --with-tcl-tk
with no luck. I only get the error Error: invalid option: --with-tcl-tk
.
I have tried to uninstall and reinstall completely a few times with no luck. I am using Tk version 8.5.9, I have updated that with brew but it seems that python is still using the old version.
Upvotes: 0
Views: 791
Reputation: 19219
I just today update my Macbook Air to Mojave and Python 3.7.1, the latter with the PSF python.org installer, which installs tcl/tk 8.6.8 and tkinter compiled to work with that. IDLE tests pass and IDLE runs normally as far as I manually tested. I strongly recommend you do the same. I cannot support any other installation.
In my opinion, https://www.python.org/download/mac/tcltk/ should be updated to call 8.5.9 'Not Recommended'. See the last section "How Python Chooses Which Tk Library To Use" on how to get Python to recognize a newer 8.5.x
Apparently, there are even issues with tk 8.6.8 on Mojave. The Mac tk developer just wrote on the Python tracker today that there are changes in tk tip to accommodate Mojave API changes. 8.5 is no longer being updated.
Upvotes: 0
Reputation: 1734
While I don't know what the cause is, I was able to find a solution.
In idlelib/editor.py
If, you comment-out line 149, IDLE stops crashing when you try to scroll.
149 text.bind('<MouseWheel>', self.mousescroll)
150 text.bind('<Button-4>', self.mousescroll)
151 text.bind('<Button-5>', self.mousescroll)
This needs to be changed to:
149 ##text.bind('<MouseWheel>', self.mousescroll) # Now IDLE should work
150 text.bind('<Button-4>', self.mousescroll)
151 text.bind('<Button-5>', self.mousescroll)
This also seems to not break anything, but does fix the issue.
You can find this file by running
>>> import idlelib.editor
>>> idlelib.editor
<module 'idlelib.editor' from '/usr/local/Cellar/python/3.7.2_2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/idlelib/editor.py'>
>>>
Tested:
macOS Mojave 10.14.3
Python 3.7.2 (From brew install python
)
Tcl/Tk (8.5.9)
Update
The problem was also corrected by reinstall python from python.org. Previously I was using a brew installation, which seems to have introduced the problem.
Upvotes: 2