Open bzijlema opened 5 years ago
Are you sure joblib is something that should run from application server as uwsgi?
I found out that the error is caused by the PYTHONDONTWRITEBYTECODE environment variable. When this variable is set, the error shows when a module is imported.
According to the python docs (https://docs.python.org/3.5/using/cmdline.html#envvar-PYTHONDONTWRITEBYTECODE), setting this variable is equivalent to runing python with the "-B" parameter. It seems that this parameter is sent to uWSGI instead of python for some reason. This looks like a bug in uWSGI or the python plugin to me.
I too notice this error. Although the deployment in my case is all with docker containers built on Ubuntu 18.04 base images. Python 3.6.6 and uwsgi 2.0.17.1.
I too have the PYTHONDONTWRITEBYTECODE in my image and I too use sklearn and joblib in my code base. However unlike the OP I actually do have a flask web app that nginx talks to through uwsgi.
I am trying to reproduce this error without having to share the code base that I am working with. But that is a bit involved so kindly allow me some time.
I was NOT able to reproduce this error with PYTHONDONTWRITEBYTECODE alone and a simple docker image. So I don't think this is being caused by PYTHONDONTWRITEBYTECODE alone.
I'm getting the following error when importing joblib from scikit-learn using uWSGI:
/tmp/uwsgi/venv/bin/uwsgi: invalid option -- 'B'
I run uWSGI with this parameters:
uwsgi --wsgi-file main.py --http :9000
main.py:
Output of pip freeze:
Python version is 3.5.2
Commenting the import of joblib removes the error. Any ideas where this error is coming from?