AttributeError: module 'moulinette.interfaces' has no attribute 'api'

Hey everybody,

I ran across an error on my server. The server got updated to 4.2 on sunday. Shortly after I noticed the error regarding the api. It got fixed by following the steps @Aleks wrote here: The YunoHost API is not responding after upgrading to 4.2.4 / greenlet.greenlet size changed

Shortly after I noticed that I was again unable to access the yunohost admin panel. The api is (again) down, and whenever I enter a command in cli it gives me this error:

admin@control:~$ sudo yunohost service restart yunohost-api
Traceback (most recent call last):
File “/usr/lib/python3.7/logging/config.py”, line 387, in resolve
found = getattr(found, frag)
AttributeError: module ‘moulinette.interfaces’ has no attribute ‘api’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/lib/python3.7/logging/config.py”, line 389, in resolve
self.importer(used)
File “/usr/lib/python3/dist-packages/moulinette/interfaces/api.py”, line 9, in
from gevent import sleep
ModuleNotFoundError: No module named ‘gevent’

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “/usr/lib/python3.7/logging/config.py”, line 562, in configure
handler = self.configure_handler(handlers[name])
File “/usr/lib/python3.7/logging/config.py”, line 712, in configure_handler
klass = self.resolve(cname)
File “/usr/lib/python3.7/logging/config.py”, line 396, in resolve
raise v
File “/usr/lib/python3.7/logging/config.py”, line 389, in resolve
self.importer(used)
File “/usr/lib/python3/dist-packages/moulinette/interfaces/api.py”, line 9, in
from gevent import sleep
ValueError: Cannot resolve ‘moulinette.interfaces.api.APIQueueHandler’: No module named ‘gevent’

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File “/usr/bin/yunohost”, line 72, in
parser=parser
File “/usr/lib/moulinette/yunohost/init.py”, line 19, in cli
init_logging(interface=“cli”, debug=debug, quiet=quiet)
File “/usr/lib/moulinette/yunohost/init.py”, line 146, in init_logging
configure_logging(logging_configuration)
File “/usr/lib/python3/dist-packages/moulinette/utils/log.py”, line 68, in configure_logging
dictConfig(logging_config)
File “/usr/lib/python3.7/logging/config.py”, line 799, in dictConfig
dictConfigClass(config).configure()
File “/usr/lib/python3.7/logging/config.py”, line 570, in configure
‘%r’ % name) from e
ValueError: Unable to configure handler ‘api’

I lack understanding so I hope somebody could help me out. What could be the cause of this error? Updating, upgrading etc… all is impossible as well and give me the same error.

Regards,

Skylar

Uhokay, can you check the output of

dpkg --list | grep python3-gevent

On my side I have (ignoring column archs and descriptions)

ii  python3-gevent                        1.3.7-1
ii  python3-gevent-websocket              0.10.1-3+ynh10

Hi Aleks,

Thanks for your reply! I get the following:

admin@control:~$ sudo dpkg --list | grep python3-gevent
ii python3-gevent 1.3.7-1 amd64 gevent is a coroutine-based Python networking library
ii python3-gevent-websocket 0.10.1-3+ynh10 all websocket library for the gevent networking library (Python 3)
admin@control:~$

It seems to be the same.

What about pip3 freeze |grep gevent

Thanks again :slight_smile:

Unfortunately the command (sudo or not) does not give an error or any information (lines). Is that a good sign?

Weeeell it could have been an explanation to what’s happening, similar to greenlet, but nope …

So let’s try something else, does python3 -c 'import gevent; print(gevent)' display an error ?

What about ls -l /usr/lib/python3/dist-packages/gevent/__init__.py

Yes it does:

admin@control:~$ python3 -c ´import gevent; print(gevent)´
-bash: syntax error near unexpected token `gevent'

But I´m not quite sure if that helps…

I also able to get this information:

root@control:/usr/lib/python3/dist-packages# ls -l /usr/lib/python3/dist-packages/gevent/__init__.py
ls: cannot access '/usr/lib/python3/dist-packages/gevent/__init__.py': No such file or directory

I was checking (as you can see :slight_smile: ), but there is no gevent in dist-packages.

Should I install the package python-gevent? Apt-install python-gevent

It installs python-greenlet as well if I would continue to install.

root@control:/usr/lib/python3/dist-packages# apt-get install python-gevent
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  python-greenlet
Suggested packages:
  python-gevent-doc python-gevent-dbg python-openssl python-greenlet-doc python-greenlet-dev python-greenlet-dbg
The following NEW packages will be installed:
  python-gevent python-greenlet
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/856 kB of archives.
After this operation, 3,527 kB of additional disk space will be used.
Do you want to continue? [Y/n]

You wrote ` instead of ’

No, because the relevant package is python3-gevent and dpkg says it’s already installed

Oh, how stupid… It was a long day

root@control:/usr/lib/python3/dist-packages# python3 -c 'import gevent; print(gevent)'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'gevent'

Wokay, and what about ls -l ls -l /usr/lib/python3/dist-packages/gevent (this time without the __init__.py at the end)

My best guess so far is to force-reinstall the python package with

apt install python3-gevent --reinstall
2 Likes

Thank you. I get the following:

root@control:/# ls -l /usr/lib/python3/dist-packages/gevent
ls: cannot access '/usr/lib/python3/dist-packages/gevent': No such file or directory

I will try :slight_smile:

Thank you!

That was teachable. It worked out.

After re-installing python3-gevent, I got the same error (OP) but with geventwebsocket.

root@control:/# yunohost tools update
Traceback (most recent call last):
  File "/usr/lib/python3.7/logging/config.py", line 387, in resolve
    found = getattr(found, frag)
AttributeError: module 'moulinette.interfaces' has no attribute 'api'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.7/logging/config.py", line 389, in resolve
    self.importer(used)
  File "/usr/lib/python3/dist-packages/moulinette/interfaces/api.py", line 11, in <module>
    from geventwebsocket import WebSocketError
ModuleNotFoundError: No module named 'geventwebsocket'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib/python3.7/logging/config.py", line 562, in configure
    handler = self.configure_handler(handlers[name])
  File "/usr/lib/python3.7/logging/config.py", line 712, in configure_handler
    klass = self.resolve(cname)
  File "/usr/lib/python3.7/logging/config.py", line 396, in resolve
    raise v
  File "/usr/lib/python3.7/logging/config.py", line 389, in resolve
    self.importer(used)
  File "/usr/lib/python3/dist-packages/moulinette/interfaces/api.py", line 11, in <module>
    from geventwebsocket import WebSocketError
ValueError: Cannot resolve 'moulinette.interfaces.api.APIQueueHandler': No module named 'geventwebsocket'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/bin/yunohost", line 72, in <module>
    parser=parser
  File "/usr/lib/moulinette/yunohost/__init__.py", line 19, in cli
    init_logging(interface="cli", debug=debug, quiet=quiet)
  File "/usr/lib/moulinette/yunohost/__init__.py", line 146, in init_logging
    configure_logging(logging_configuration)
  File "/usr/lib/python3/dist-packages/moulinette/utils/log.py", line 68, in configure_logging
    dictConfig(logging_config)
  File "/usr/lib/python3.7/logging/config.py", line 799, in dictConfig
    dictConfigClass(config).configure()
  File "/usr/lib/python3.7/logging/config.py", line 570, in configure
    '%r' % name) from e
ValueError: Unable to configure handler 'api'

apt install python3-gevent-websocket --reinstall
Fixed it

After that one more error showed up:

root@control:/# yunohost tools update                           
Info: Fetching available upgrades for system packages...
Info: Updating application catalog…
Success! The application catalog has been updated!
Traceback (most recent call last):
  File "/usr/bin/yunohost", line 72, in <module>
    parser=parser
  File "/usr/lib/moulinette/yunohost/__init__.py", line 25, in cli
    ret = moulinette.cli(args, output_as=output_as, timeout=timeout, top_parser=parser)
  File "/usr/lib/python3/dist-packages/moulinette/__init__.py", line 120, in cli
    args, output_as=output_as, timeout=timeout
  File "/usr/lib/python3/dist-packages/moulinette/interfaces/cli.py", line 502, in run
    ret = self.actionsmap.process(args, timeout=timeout)
  File "/usr/lib/python3/dist-packages/moulinette/actionsmap.py", line 600, in process
    return func(**arguments)
  File "/usr/lib/moulinette/yunohost/tools.py", line 490, in tools_update
    upgradable_apps = list(_list_upgradable_apps())
  File "/usr/lib/moulinette/yunohost/tools.py", line 503, in _list_upgradable_apps
    app_dict = app_info(app_id, full=True)
  File "/usr/lib/moulinette/yunohost/app.py", line 197, in app_info
    permissions = user_permission_list(full=True, absolute_urls=True, apps=[app])[
  File "/usr/lib/moulinette/yunohost/permission.py", line 57, in user_permission_list
    from yunohost.utils.ldap import _get_ldap_interface, _ldap_path_extract
  File "/usr/lib/moulinette/yunohost/utils/ldap.py", line 25, in <module>
    from moulinette.authenticators import ldap
  File "/usr/lib/python3/dist-packages/moulinette/authenticators/ldap.py", line 7, in <module>
    import ldap
  File "/usr/lib/python3/dist-packages/ldap/__init__.py", line 94, in <module>
    from ldap.functions import initialize,get_option,set_option,escape_str,strf_secs,strp_secs
  File "/usr/lib/python3/dist-packages/ldap/functions.py", line 24, in <module>
    from ldap.ldapobject import LDAPObject
  File "/usr/lib/python3/dist-packages/ldap/ldapobject.py", line 29, in <module>
    from ldap.controls import LDAPControl,DecodeControlTuples,RequestControlTuples
  File "/usr/lib/python3/dist-packages/ldap/controls/__init__.py", line 20, in <module>
    from pyasn1.error import PyAsn1Error
ModuleNotFoundError: No module named 'pyasn1'

root@control:/# apt install python3-pyasn1 --reinstall

Fixed that :slight_smile:

Everything is working as it should now. Thanks a bunch!

The server has been running for over 2 years now… I guess It was due time something broke :slight_smile:

@Skylar This issue came because of the Zeronet problem. As Yunohost moved to python3 this package break things in Yunohost.

As a precaution please check if you still have Zeronet installed on the Yunohost server. The package would be totally in broken condition right now if present.
Beware: Don’t try to uninstall it right now if the package is present. It would break Yunohost again.

New PR is coming which will have to be force updated to Zeronet after which uninstall process should be done.

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.