according to the Documentation i am supposed to start gunicorn with /path/to/paperless.wsgi -w 2
Unfortunately there is no file named paperless.wsgi to be found anywhere in the paperless installation?
Does this work for you?
PYTHONPATH="path/to/paperless/src:$PYTHONPATH" gunicorn paperless.wsgi
no, same problem: there is no file named paperless.wsgi...
No, but there's a Python module paperless.wsgi (wsgi.py), relative to paperless/src.
Please post the exact whole command line that sets the PYTHONPATH like above but still doesn't work for you.
ExecStart=/opt/paperless/.local/bin/gunicorn /opt/paperless/src/paperless/wsgi.py -w 2
didn't explicitly set a path, used native installed python3 on debian i guess
i simply switched to apache2, but one might still clear it up for future users...
Does it work now?
Picking up this issue instead of starting a new one:
PYTHONPATH="/home/goose/bin/paperless/src:${PYTHONPATH}" /usr/local/bin/gunicorn paperless.wsgi -w 2 -b 127.0.0.1:7412
Does work for me. However, this does not:
```
goose@eddard:~/bin/paperless/src/paperless$ /usr/local/bin/gunicorn /home/goose/bin/paperless/src/paperless/wsgi.py -w 2 -b 127.0.0.1:7412
[2018-10-08 10:11:55 -0400] [27106] [INFO] Starting gunicorn 19.9.0
[2018-10-08 10:11:55 -0400] [27106] [INFO] Listening at: http://127.0.0.1:7412 (27106)
[2018-10-08 10:11:55 -0400] [27106] [INFO] Using worker: sync
[2018-10-08 10:11:55 -0400] [27110] [INFO] Booting worker with pid: 27110
[2018-10-08 10:11:55 -0400] [27110] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/home/goose/.local/lib/python3.5/site-packages/gunicorn/util.py", line 350, in import_app
__import__(module)
ImportError: No module named '/home/goose/bin/paperless/src/paperless/wsgi'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/goose/.local/lib/python3.5/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
worker.init_process()
File "/home/goose/.local/lib/python3.5/site-packages/gunicorn/workers/base.py", line 129, in init_process
self.load_wsgi()
File "/home/goose/.local/lib/python3.5/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
self.wsgi = self.app.wsgi()
File "/home/goose/.local/lib/python3.5/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/home/goose/.local/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
return self.load_wsgiapp()
File "/home/goose/.local/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
return util.import_app(self.app_uri)
File "/home/goose/.local/lib/python3.5/site-packages/gunicorn/util.py", line 354, in import_app
raise ImportError(msg % (module.rsplit(".", 1)[0], obj))
ImportError: Failed to find application, did you mean '/home/goose/bin/paperless/src/paperless/wsgi:application'?
[2018-10-08 10:11:55 -0400] [27110] [INFO] Worker exiting (pid: 27110)
[2018-10-08 10:11:55 -0400] [27106] [INFO] Shutting down: Master
[2018-10-08 10:11:55 -0400] [27106] [INFO] Reason: Worker failed to boot.
goose@eddard:~/bin/paperless/src/paperless$ /usr/local/bin/gunicorn /home/goose/bin/paperless/src/paperless/wsgi:application -w 2 -b 127.0.0.1:7412
[2018-10-08 10:12:04 -0400] [27114] [INFO] Starting gunicorn 19.9.0
[2018-10-08 10:12:04 -0400] [27114] [INFO] Listening at: http://127.0.0.1:7412 (27114)
[2018-10-08 10:12:04 -0400] [27114] [INFO] Using worker: sync
[2018-10-08 10:12:04 -0400] [27118] [INFO] Booting worker with pid: 27118
[2018-10-08 10:12:04 -0400] [27118] [ERROR] Exception in worker process
Traceback (most recent call last):
File "/home/goose/.local/lib/python3.5/site-packages/gunicorn/arbiter.py", line 583, in spawn_worker
worker.init_process()
File "/home/goose/.local/lib/python3.5/site-packages/gunicorn/workers/base.py", line 129, in init_process
self.load_wsgi()
File "/home/goose/.local/lib/python3.5/site-packages/gunicorn/workers/base.py", line 138, in load_wsgi
self.wsgi = self.app.wsgi()
File "/home/goose/.local/lib/python3.5/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/home/goose/.local/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 52, in load
return self.load_wsgiapp()
File "/home/goose/.local/lib/python3.5/site-packages/gunicorn/app/wsgiapp.py", line 41, in load_wsgiapp
return util.import_app(self.app_uri)
File "/home/goose/.local/lib/python3.5/site-packages/gunicorn/util.py", line 350, in import_app
__import__(module)
ImportError: No module named '/home/goose/bin/paperless/src/paperless/wsgi'
[2018-10-08 10:12:04 -0400] [27118] [INFO] Worker exiting (pid: 27118)
[2018-10-08 10:12:04 -0400] [27114] [INFO] Shutting down: Master
[2018-10-08 10:12:04 -0400] [27114] [INFO] Reason: Worker failed to boot.
goose@eddard:~/bin/paperless/src/paperless$```
There seems to be a misconception that wsgi.py should be referenced as a file. This is not the case. As @erikarvstedt points out, Gunicorn expects to get a module path and not a file path. As such, you need to define the path to that file with . within the PYTHONPATH and not a file path from the filesystem root.
As we have to working examples here (one with Apache's mod_wsgi I assume, and the other with Gunicorn), I'm going to close this now.
@danielquinn I think the incorrect thinking is coming from the docs - https://paperless.readthedocs.io/en/latest/setup.html?highlight=static#nginx-gunicorn
I just hit the same problem, but resolve it by setting the python path as per @goose-ws
Thanks for the heads-up @cyclingengineer . I don't suppose you'd be willing to write a pull-request to fix this in the docs?
Most helpful comment
@danielquinn I think the incorrect thinking is coming from the docs - https://paperless.readthedocs.io/en/latest/setup.html?highlight=static#nginx-gunicorn
I just hit the same problem, but resolve it by setting the python path as per @goose-ws