2

I am trying to get a Celery worker running via supervisord

$ sudo supervisorctl reread
$ sudo supervisorctl update
$ sudo supervisorctl start my_app_celery_worker

Inspecting the logs, I see

ImportError: No module named site

Could someone please suggest what causes (even better if how to resolve) this error?

Thanks in advance.


I am using

  • Ubuntu 14.04.4 LTS (GNU/Linux 3.13.0-87-generic x86_64)
  • celery (3.1.23)
  • virtualenv (15.0.2)

I have installed the required packages into the virtualenv, venv1.

Permissions for proj and logs folders,

drwx------ 3 bob  bob  4096 Jul 14 03:24 logs
drwx------ 4 bob  bob  4096 Jul 14 00:12 proj

Permissions for venv1 subfolder,

$ ls -lrt ~/proj/my_app
-rw-rw-r-- 1 bob  bob  4852 Jul 13 19:09 celery_worker.py
drwxr-xr-x 5 root root 4096 Jul 14 00:24 venv1

Python,

$ which -a python
/usr/bin/python

$ python --version
Python 2.7.6

$ python -c "import sys, pprint; pprint.pprint(sys.path)"
    ['',
     '/usr/local/lib/python2.7/site-packages',
     '/usr/lib/python2.7/plat-x86_64-linux-gnu',
     '/usr/lib/python2.7',
     '/usr/lib/python2.7/lib-tk',
     '/usr/lib/python2.7/lib-old',
     '/usr/lib/python2.7/lib-dynload',
     '/usr/local/lib/python2.7/dist-packages',
     '/usr/lib/python2.7/dist-packages']

Following the advice here, I removed the no-global-site-packages.txt file

My configuration file (/etc/supervisor/conf.d/my_app_celery_worker.conf) is similar to

[program:my_app_celery_worker]
command=/home/bob/proj/my_app/venv1/bin/celery -A tasks worker --loglevel=INFO --concurrency=9 -n worker_1
environment =
    CELERY_CONFIG = /home/bob/proj/conf/celery.cfg,
    MY_APP_CONFIG = /home/bob/proj/conf/my_app.cfg
directory = /home/bob/proj/my_app
user = bob
numprocs = 1
stdout_logfile = /home/bob/logs/proj/worker_1.log
stderr_logfile = /home/bob/logs/proj/worker_1.log
autostart = true
autorestart = true
startsecs = 10
stopwaitsecs = 600
killasgroup = true
priority = 1000
Community
  • 1
  • 1
user799188
  • 13,965
  • 5
  • 35
  • 37
  • 1
    Lots of python modules with a file `site.py` ... Suggest `sudo apt-get install libpython2.7-minimal pypy-lib` ... https://packages.debian.org/search?suite=stretch&searchon=contents&keywords=site.py – Knud Larsen Jul 15 '16 at 19:16

0 Answers0