__init__.py namespace error
I have made a mistake, and the errors I talk about here occur in the older version of easygui, 0.97
I downloaded easygui and put it in my site-packages folder. When I typed import easygui into IDLE I got this error:
Traceback (most recent call last): File "<pyshell#2>", line 1, in <module> import easygui File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/easygui/__init__.py", line 3, in <module> __all__ = easygui.__all__ NameError: name 'easygui' is not defined
So I went into the init.py and I think I found the error. In the first line it says from easygui import * which means that you don't have to put easygui. in front of easygui functions. But then in the third line it says __all__ = easygui.__all__
Python looks for easygui.all when we don't have that namespace because of the way easygui was imported.
But when I change the first line to say import easygui python gives me the error that module 'easygui' has no attribute '__all__'
What's going on?
EDIT: I think I figured how to fix it. I changed the script to this:
import easygui pass __all__ = [easygui]
EDIT 2: This has been changed it this version, it is only a problem in the older versions that you are suggested to download here, version 0.97 When will those ones be updated?
Try using 'from easygui import *' instead of 'import easygui', and you
should import everything.
Alternatively, use 'from easygui import
Attributes like 'all' are private and get name mangled. As a general rule of thumb you don't want to access things like that. You can still access private attributes if you really want. Does that help?
Ok thanks, but is there an issue with my fix?
Short answer - use v0.98 from GitHub (here!) or from PIP. I'll update SourceForge to point people here. Longer answer - I'm curious about what wasn't working and how your fix works and want to look into it. When I get the chance I'll try to reproduce it and understand how this works.
@zadacka Okay, but make sure to tell people to isolate the easygui folder from the .zip file that gets downloaded, it was a little confusing at first. Thanks!