idle crashing when I press configure idle - python

If I go on cmd and write python -m idlelib, that would open IDLE. If I were to then go on configure IDLE, on the cmd, it gives be an error
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\xxx\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py", line 1883, in __call__
return self.func(*args)
File "C:\Users\xxx\AppData\Local\Programs\Python\Python38-32\lib\idlelib\editor.py", line 574, in config_dialog
configdialog.ConfigDialog(self.top,'Settings')
File "C:\Users\xxx\AppData\Local\Programs\Python\Python38-32\lib\idlelib\configdialog.py", line 78, in __init__
self.create_widgets()
File "C:\Users\\AppData\Local\Programs\Python\Python38-32\lib\idlelib\configdialog.py", line 113, in create_widgets
self.highpage = HighPage(note)
File "C:\Users\xxx\AppData\Local\Programs\Python\Python38-32\lib\idlelib\configdialog.py", line 693, in __init__
self.load_theme_cfg()
File "C:\Users\xxx\AppData\Local\Programs\Python\Python38-32\lib\idlelib\configdialog.py", line 998, in load_theme_cfg
self.paint_theme_sample()
File "C:\Users\xxx\AppData\Local\Programs\Python\Python38-32\lib\idlelib\configdialog.py", line 1279, in paint_theme_sample
self.highlight_sample.tag_config(element, **colors)
File "C:\Users\xxx\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py", line 3854, in tag_configure
return self._configure(('tag', 'configure', tagName), cnf, kw)
File "C:\Users\xxx\AppData\Local\Programs\Python\Python38-32\lib\tkinter\__init__.py", line 1627, in _configure
self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
_tkinter.TclError: invalid color name "#00224"
I probably have a custom theme with an invalid color, however, how am I supposed to delete it if I can't access it (since it crashes when I do so).
There was a post, Python freezes when configuring IDLE that had I believe the same issue, but all he says as a solution is "manually deleting the faulty theme", which he doesn't explain. Pretty much, I want to access configure IDLE option without it crashing. Once it does crash, the only way I can close it then is by using task manager or restarting my computer.
As solution, you can tell me how to delete a custom theme without using IDLE if that's possible.

If the problem is in a custom theme, then the user configuration file you need to edit is $HOME/.idlerc/config-highlight.cfg. In your case, $HOME, based on the url below, appears to be C:/Users/chess. Just add a digit to make six. You can use the IDLE editor to do so. You should then be able to edit the color properly in the config dialog.
The problem might possibly be a character missing from the defaults file supplied with IDLE:
C:\Users\chess\AppData\Local\Programs\Python\Python38-32\lib\idlelib\config-highlight.def
Thank you for opening IDLE in a console, getting the traceback, and posting all of it. It gave me an idea of how to prevent the crash, so I opened a bug report

Related

Problem running python cProfile in VSCode debug console

I'm trying to setup a good VSCode python environment for debugging including profiling using cProfile in a REPL manner, and I really like the debug widow.
In the VSCode debugger I am able to run/debug the following script:
import cProfile
cProfile.run("10 + 10")
print("Break here")
I am using the Microsoft "Python" extension for debugging and setting the output to "internalConsole" in my "launch.json" and the cProfile output correctly shows up in the debug console window.
However, after hitting a breakpoint set at print("Break here") and manually entering the command cProfile.run("10 + 10") into the debug console window, I get the following error:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python3.8/cProfile.py", line 16, in run
return _pyprofile._Utils(Profile).run(statement, filename, sort)
File "/usr/lib/python3.8/profile.py", line 57, in run
self._show(prof, filename, sort)
File "/usr/lib/python3.8/profile.py", line 72, in _show
prof.print_stats(sort)
File "/usr/lib/python3.8/cProfile.py", line 42, in print_stats
pstats.Stats(self).strip_dirs().sort_stats(sort).print_stats()
File "/usr/lib/python3.8/pstats.py", line 96, in __init__
self.init(arg)
File "/usr/lib/python3.8/pstats.py", line 110, in init
self.load_stats(arg)
File "/usr/lib/python3.8/pstats.py", line 136, in load_stats
raise TypeError("Cannot create or construct a %r object from %r"
TypeError: Cannot create or construct a <class 'pstats.Stats'> object from <cProfile.Profile object at 0x7efee11c30a0>
I am also able to run cProfile.run("10 + 10") in a command line python session as well as in the VSCode terminal ("integratedTerminal").
Any ideas on how to fix this and why the behavior is different for the debug console window?
I tried searching information regarding the mechanisms of the debug window in comparison with terminal window but have not found anything of substance yet.

Set up Python tkTable

Being very new to Phyton, I’m trying to use tktable for Python and can’t get it run on my PC.
After searching a lot in the net, without finding any solution, I hope you find the time to help me a bit.
I’m sure this is peanuts for you.
I’m running Python 3.7 on a Windows 8.1. PC.
I’m getting this error:
_tkinter.TclError: invalid command name "table"
What I did so far:
Downloaded tktable and run the setup.py.
Copied the tktable.py to the Python site-packages folder.
Installed ActiveTcl.
Copied the three files tktable.tcl, Tktable.dll and pkgIndex.tcl from ActiveTcl (C:\ActiveTcl\lib\Tktable2.11) to C:........\Python\Python37-32\tcll\Tktable2.11.
According what I have found in the net, this should do it…
But, as I wrote, I keep getting the error I mentioned.
Michael
The content is:
C:\Users\mschuppisser.EAD\AppData\Local\Programs\Python\Python37-32\Lib\;
C:\Users\mschuppisser.EAD\AppData\Local\Programs\Python\Python37-32\DLLs\
Traceback:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\mschuppisser.EAD\AppData\Local\Programs\Python\Python37-32\lib\tkinter\__init__.py", line 1705, in __call__
return self.func(*args)
File "C:/Users/mschuppisser.EAD/Data/My Data/Python/Test Applikation/Test Applikation.py", line 267, in Jump_to_UebersichtsFenster3
application = clsUebersichtsFenster3(UebersichtsFenster3)
File "C:/Users/mschuppisser.EAD/Data/My Data/Python/Test Applikation/Test Applikation.py", line 447, in __init__
self.table_grid = tktable.Table(UebersichtsFenster3) # , state='disabled', width=50, titlerows=1, rows=5, cols=4, colwidth=20)
File "C:\Users\mschuppisser.EAD\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tktable.py", line 135, in __init__
tkinter.Widget.__init__(self, master, 'table', kw)
File "C:\Users\mschuppisser.EAD\AppData\Local\Programs\Python\Python37-32\lib\tkinter\__init__.py", line 2299, in __init__
(widgetName, self._w) + extra + self._options(cnf))
_tkinter.TclError: invalid command name "table"

tkinter.TclError: invalid command name "table"

Okay, first of all I don't know what is the actual problem here so I couldn't come up with a more accurate title. Maybe some of you can edit it to make it accurate
The following is the minimalised code to reproduce the problem I'm having.
from traybar import SysTrayIcon
from cal import Calendar
import Tkinter
class Add():
def __init__(self,master):
Calendar(master).pack()
def add(systray):
root = Tkinter.Tk()
Add(root)
root.mainloop()
SysTrayIcon("abc.ico","abc", (('Add',None, add), ) ,default_menu_index=0).start()
The cal and the trabar are these files http://tkinter.unpythonic.net/wiki/TkTableCalendar and https://github.com/Infinidat/infi.systray/blob/develop/src/infi/systray/traybar.py respectively.
If you run this, it will make a icon in the system tray of a windows machine with the options Add and Quit. clicking on the app opens up the calender, no problem. Close the calender and click on the Add again. But this time it doesn't open the calendar and throws the following error
`
Traceback (most recent call last):
File "_ctypes/callbacks.c", line 314, in 'calling callback function'
File "C:\Users\Koushik Naskar\AppData\Roaming\Python\Python27\site-packages\traybar.py", line 79, in WndProc
self._message_dict[msg](hwnd, msg, wparam.value, lparam.value)
File "C:\Users\Koushik Naskar\AppData\Roaming\Python\Python27\site-packages\traybar.py", line 276, in _command
self._execute_menu_option(id)
File "C:\Users\Koushik Naskar\AppData\Roaming\Python\Python27\site-packages\traybar.py", line 283, in _execute_menu_option
menu_action(self)
File "C:\Users\Koushik Naskar\Desktop\So\temp.py", line 11, in add
Add(root)
File "C:\Users\Koushik Naskar\Desktop\So\temp.py", line 7, in __init__
Calendar(master).pack()
File "C:\Users\Koushik Naskar\Desktop\So\cal.py", line 66, in __init__
state='disabled', browsecommand=self._set_selection)
File "C:\Python27\lib\lib-tk\tktable.py", line 118, in __init__
Tkinter.Widget.__init__(self, master, 'table', kw)
File "C:\Python27\lib\lib-tk\Tkinter.py", line 2090, in __init__
(widgetName, self._w) + extra + self._options(cnf))
_tkinter.TclError: invalid command name "table"
`
This problem only appears when I use SysTrayIcon with the Calendar.Instead of Calendar if you use simple Tkinter Button or Label etc. this error doesn't appear. Also I can use the Calendar widget normally (without the SysTrayIcon ) in a usual Tkinter GUI as many times as I want, no error occur there. Now I don't have any clue about whats happenning here and how to fix this. What problem does SysTrayIcon have with Calendar and Why the error doesn't happen the first time I open the GUI? Please help.
TkTableCalendar requies the tktable module, which you have installed in lib-tk (3rd party modules usually go into lib/site-packages) as indicated by this part of the traceback.
File "C:\Python27\lib\lib-tk\tktable.py", line 118, in __init__
Tkinter.Widget.__init__(self, master, 'table', kw)
The tktable module requires that your tcl/tk installation have the tktable extension. That extension defines the 'table' widget. It is not part of the standard tcl/tk that is installed with Python on Windows. Hence
_tkinter.TclError: invalid command name "table"
The tktable source code (probably a mixture of tcl and C) is hosted at SourceForge. This page says that it is part of the ActiveState Batteries Included distribution. I don't know if the free version of AS tcl/tk has all the 'batteries'. And I don't know how to replace the tcl/tk installation you already have with a new one. I personally would use an alternative if possible.

How to run python programs in pycharm with passing parameters?

I am currently having problem running python programs in pycharm, I generally used to right click and run the program. I want to run the program like this:
python hrllo.py rahulkapoo vit university
Here is the error I get:
Traceback (most recent call last):
File "C:/Users/rahul/PycharmProjects/untitled/hrllo.py", line 107, in <module>
aggregate()
File "C:/Users/rahul/PycharmProjects/untitled/hrllo.py", line 88, in aggregate
br = login()
File "C:/Users/rahul/PycharmProjects/untitled/hrllo.py", line 23, in login
response = br.open('https://academics.vit.ac.in/student/stud_login.asp')
File "C:\Python27\lib\site-packages\mechanize\_mechanize.py", line 203, in open
return self._mech_open(url, data, timeout=timeout)
File "C:\Python27\lib\site-packages\mechanize\_mechanize.py", line 255, in _mech_open
raise response
mechanize._response.httperror_seek_wrapper: HTTP Error 403: request disallowed by robots.txt
Process finished with exit code 1
In PyCharm, right-click on the script (or within the editor window that has the script open, click Create 'scriptname', put your params in the Script Parameters box near the top and click OK.
The new run config will appear to the left of the run button at the top of Pycharm (at least in my version it does). Now make sure that the new run config is listed when running the script.

Spyder: typing an opening bracket in console puts focus on internal console

I have recently re-installed spyder on ubuntu 12.04. Here is the problem:
When I type an opening bracket in the console, the focus switches immediately to the internal console, displaying an error (that I interpret as "missing closing bracket"?) While I appreciate the code monitoring, it would be nice if the console let me finish my line of code first before jumping to conclusions.
How can I avoid this behavior? (I dont mind the "error" showing in the internal console, but the switch to the internal console whenever I open a bracket is quite disruptive.)
Here is the output of the internal console:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/spyder-2.3.0-py2.7.egg/spyderlib/widgets/shell.py", line 298, in keyPressEvent
self.postprocess_keyevent(event)
File "/usr/local/lib/python2.7/dist-packages/spyder-2.3.0-py2.7.egg/spyderlib/widgets/shell.py", line 727, in postprocess_keyevent
ShellBaseWidget.postprocess_keyevent(self, event)
File "/usr/local/lib/python2.7/dist-packages/spyder-2.3.0-py2.7.egg/spyderlib/widgets/shell.py", line 438, in postprocess_keyevent
self._key_parenleft(text)
File "/usr/local/lib/python2.7/dist-packages/spyder-2.3.0-py2.7.egg/spyderlib/widgets/shell.py", line 797, in _key_parenleft
self.show_object_info(last_obj, call=True)
File "/usr/local/lib/python2.7/dist-packages/spyder-2.3.0-py2.7.egg/spyderlib/widgets/mixins.py", line 608, in show_object_info
signature=True, color='#2D62FF')
File "/usr/local/lib/python2.7/dist-packages/spyder-2.3.0-py2.7.egg/spyderlib/widgets/mixins.py", line 108, in show_calltip
self.calltip_widget.show_tip(point, tiptext, wrapped_textlines)
File "/usr/local/lib/python2.7/dist-packages/spyder-2.3.0-py2.7.egg/spyderlib/widgets/calltip.py", line 157, in show_tip
forward=False)
File "/usr/local/lib/python2.7/dist-packages/spyder-2.3.0-py2.7.egg/spyderlib/widgets/calltip.py", line 252, in _find_parenthesis
while category(char) != 'Cc' and position > 0:
TypeError: need a single Unicode character as parameter
To not show errors on the Internal console, you need to go to
Tools > Preferences > General > Debugging
and deactivate the option called
[ ] Pop up internal console when internal errors appear

Categories