KeyError: "zope" when running some Python applications (supervisor, gunicorn, ...)

I'm not sure if the problem is really with supervisord, but this is what I get when I try to run it. It looks like the problem will be with Python2 itself ...

$ supervisord
Traceback (most recent call last):
  File "/usr/bin/supervisord", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2727, in <module>
    add_activation_listener(lambda dist: dist.activate())
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 700, in subscribe
    callback(dist)
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2727, in <lambda>
    add_activation_listener(lambda dist: dist.activate())
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2230, in activate
    map(declare_namespace, self._get_metadata('namespace_packages.txt'))
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 1815, in declare_namespace
    path = sys.modules[parent].__path__
KeyError: 'zope'

      

My memory may betray me, but I feel like remembering that it happened to me when I tried to run another program, but I don't remember which atm. [1]

I use supervisord for monitore if one of the processes crashes and restarts it automatically, but if it interrupts continuously it refuses and I have to kill the super save and restart it manually. It worked, but no more.

EDIT: [1] Also happens when I try to run an action movie.

$ /var/www/bin/gunicorn -b 127.0.0.1:5000 index:app
Traceback (most recent call last):
  File "/var/www/bin/gunicorn", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/var/www/lib/python3.3/site-packages/pkg_resources.py", line 3027, in <module>
    add_activation_listener(lambda dist: dist.activate())
  File "/var/www/lib/python3.3/site-packages/pkg_resources.py", line 741, in subscribe
    callback(dist)
  File "/var/www/lib/python3.3/site-packages/pkg_resources.py", line 3027, in <lambda>
    add_activation_listener(lambda dist: dist.activate())
  File "/var/www/lib/python3.3/site-packages/pkg_resources.py", line 2514, in activate
    list(map(declare_namespace, self._get_metadata('namespace_packages.txt')))
  File "/var/www/lib/python3.3/site-packages/pkg_resources.py", line 2082, in declare_namespace
    path = sys.modules[parent].__path__
KeyError: 'zope'

      

EDIT 2: Seems to be related to this issue: https://bugs.launchpad.net/ubuntu/+source/zope.app.pagetemplate/+bug/851038 ... but I'm not sure what to do about it. EDIT EDIT: Well, maybe not, it's 4 years old.

Yes, I am also using Ubuntu server.

+3


source to share


1 answer


Based on lengthy chat discussion , the problem is you messed up your env in such a way that some python installations on your system get confused.

The file .bashrc

contains a line export PYTHONPATH=/usr/local/lib/python3.3/dist-packages/

. However, all Python will use this path, even Python 2.



You have installed supervisor and gunicorn with apt and these versions use python2. When you run gunicorn

this command uses python2, which picks up the PYTHONPATH with Python 3 on it. Something along the line is trying to test the path and get confused in some way.

Remove the line in the file .bashrc

by changing the PYTHONPATH value.

+2


source







All Articles