-1

I have setup flask with apache (wsgi) under a venv running python 3.6 on ubuntu 18.04 lts and imported other modules with success. Including celery with rabbitmq.

I followed this guidance for Celery and Flask https://flask.palletsprojects.com/en/1.1.x/patterns/celery/ and am semi confident celery is called by flask. Because when I run celery worker -A views.celery it successfully runs and I can see the workers collecting the tasks from what I guess is the rabbitmq queue. (I'm still getting my head around all this).

When I follow the numerous guides online to use systemd or init.d or even the older supervisord I come in to the same problem, which mirrors this Python - Module Not Found but I have followed it without success.

So to confirm, my error is ImportError: attempted relative import with no known parent package and the line in question was from views.celery with line from .static.py.forms import blah where static is the usual flask directory, and py is a directory where I store a forms. py file.

So because this is using relative importing (So I'm to believe because of the period . ) I remove the period. Flask continues to work. But the new error I receive is module static.py was not found

Following the guidance from the other stackoverflow question, I added a Environment=PATH="/var/www/Flask/app/" in the Unit celeryd file. I also have since added blank __init__. py files in the directories static and py.

Appreciate any assistance!!

I have also used these resources but suspect due to my lack of knowledge I have made an error somewhere.

https://medium.com/@MicroPyramid/celery-with-supervisor-12522ec397ed
https://github.com/celery/celery/blob/3.1/extra/supervisord/celeryd.conf
https://docs.celeryproject.org/en/4.4.2/userguide/daemonizing.html#daemon-systemd-generic
https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units
https://stackoverflow.com/questions/21880360/daemonizing-celery
https://www.cyberciti.biz/faq/unix-create-user-account/
https://www.maketecheasier.com/add-remove-user-to-groups-in-ubuntu/
https://stackoverflow.com/questions/16981921/relative-imports-in-python-3
https://napuzba.com/a/import-error-relative-no-parent
Bob Trial
  • 9
  • 3
  • I always solve this "problem" by exporting PYTHONPATH to the correct value (the top level directory path of your project). – DejanLekic May 15 '20 at 16:46

1 Answers1

0

fixed. It was because I had a folder named 'py'

-_- so annoying

Bob Trial
  • 9
  • 3