1

I got below error when import easygui in Python3.5

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    import easygui
  File "C:\Users\bhongtip\AppData\Local\Programs\Python\Python35-32\lib\site-packages\easygui-0.98.0-py3.5.egg\easygui\__init__.py", line 50, in <module>
    from .boxes.choice_box import choicebox
  File "C:\Users\bhongtip\AppData\Local\Programs\Python\Python35-32\lib\site-packages\easygui-0.98.0-py3.5.egg\easygui\boxes\choice_box.py", line 76
    except Exception, e:
                    ^
SyntaxError: invalid syntax
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343

3 Answers3

3

This issue was fixed in EasyGUI 0.98.1, which includes the change I suggested in my original answer below.

If you are still encountering this issue, upgrade to the latest release with

pip install -U "easygui>=0.98.1"

My original answer:

EasyGUI 0.98 introduced a change incompatible with Python 3.

You'll need to either downgrade to 0.97.4 (pip install -U EasyGUI==0.97.4) or fix that change.

Fixing that line is as easy as replacing line 76:

except Exception, e:

with

except Exception as e:

This is tracked as issue #97 by the project (with duplicates #101 and #102, and pull requests #100, #103, #105 and #107).

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
0

I see the easygui you have is for python 2.7.there are 2 things you can do.

  1. go to the C:\Users\bhongtip\AppData\Local\Programs\Python\Python35-32\lib\site-packages\easygui-0.98.0-py3.5.egg\easygui\boxes\choice_box.py and change the line to except (Exception, e): but that wouldn't solve all the problems.

  2. open cmd and type pip3 uninstall easygui then after that has been run type pip3 install --user easygui that should install the correct version for your python 3.5

jrswgtr
  • 2,287
  • 8
  • 23
  • 49
l. zhang
  • 335
  • 3
  • 5
  • Yes, the problem has *long* since been fixed. Installing the current version is certainly preferable. – Martijn Pieters Jan 06 '19 at 13:18
  • Note that your suggested edit to my post was wrong, see [Python - except (OSError, e) - No longer working in 3.3.3?](//stackoverflow.com/q/20517785) for why the change you made would break code. – Martijn Pieters Jan 06 '19 at 13:22
0

have you tried using:

from easygui import *

this is what I have always used and uhave used choicebox before.