I can't print from Python IDLE in Windows 10

2019-08-14 07:16发布

问题:

Since upgrading to Windows 10 I can no longer print from the IDLE Python IDE. The "print to default printer" box comes up as usual, but nothing is sent to the print queue ... I checked in Devices & Printers.

Printing from other applications works fine.

回答1:

I confirmed on my Win10 machine. However for me, the problem is not with Win 10. It is a stupid bug that I introduced in 2.7.11, 3.4.4, and 3.5.1. I am assuming that you must have upgraded Python also. You can test if you have the same cause by running python -m idlelib (or idlelib.idle on 2.7) in a console. After IDLE starts, try to print and you should see a traceback ending with NameError: name 'idleConf' is not defined.

My apologies for the blunder. I will fix this for future releases as soon as I finish improving the test so it would have caught this.

To fix it in the meanwhile, carefully edit <python-dir>/Lib/idlelib/IOBinding.py. Move this line

from idlelib.configHandler import idleConf

from about line 530, after a tkinter import, to line 13, after an askstring import. Remove the indent when you do so.