3

Python 3.5.2, Mint Linux 32-bit.

I've followed the documentation here -- https://pypi.org/project/python-zenity/#example -- and tried variations thereof, BUT cannot import the zenity library into Python 3.

  1. pip3 search zenity RESULT:

    python-zenity (0.1.3) - Simple dialog with Python and Gtk

  2. sudo -H pip3 install python-zenity RESULT:

    Collecting python-zenity Installing collected packages: python-zenity Running setup.py install for python-zenity ... done Successfully installed python-zenity-0.1.3

  3. pip3 list | grep zenity RESULT:

    python-zenity 0.1.3

  4. python3 RESULT:

    Python 3.5.2 (default, Nov 12 2018, 13:43:14)
    [GCC 5.4.0 20160609] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>>

  5. import pythonzenity RESULT:

    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File "/usr/local/lib/python3.5/dist-packages/pythonzenity/__init__.py", line 1, in <module>
    from python_zenity import *
    ImportError: No module named 'python_zenity'

And variations of python-zenity, python_zenity, from pythonzenity import * (just to try to get import to work), and so on.

What's the "trick" to import the python-zenity library that pip3 tells me I've successfully installed?


EDIT:

Per metatoaster's answer, uninstalled pyththon-zenity, installed zenipy. import zenipy worked straightaway:

>>> import zenipy
>>> dir(zenipy)
['__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'calendar', 'color_selection', 'entry', 'error', 'file_selection', 'message', 'password', 'question', 'scale', 'warning', 'zenipy', 'zlist']
>>> 
RBV
  • 1,367
  • 1
  • 14
  • 33

1 Answers1

4

The exception message is actually generated by the package itself - its __init__.py define a relative import which is no longer supported. If you don't mind manually correcting the statement inside (as per the Traceback) /usr/local/lib/python3.5/dist-packages/pythonzenity/__init__.py, change the import * line to:

 from .python_zenity import *

Which should trigger the imports.

Alternatively, refer to the linked Git repository which actually had a package name change and the import statements are now done via the proper relative import syntax in the same __init__.py file.

The better solution is to install the current version of the package under its new name, zenipy.

metatoaster
  • 17,419
  • 5
  • 55
  • 66
  • I edited my question to include that after uninstalling python-zenity and installing zenipy I was able to import zenipy straightaway... – RBV Feb 13 '19 at 19:14