Having problems getting django 3 and mod_wsgi working

I am trying to get django 3, python 3.6.6, apache 2.4.38, and mod_wsgi (libapache2-mod-wsgi-py3 4.6.5-1)to play nicely on my Debian buster linode, and they aren't

I am getting the error:

Fatal Python error: initfsencoding: unable to load the file system codec
ModuleNotFoundError: No module named 'encodings'

I have googled the error and tried lots of solutions but nothing seems to work.

I posted a detailed description to stackoverflow: [https://stackoverflow.com/questions/63960149/wsgi-error-no-module-named-encodings-using-python-3-6-6-django-3-apache-2-4].

If anyone has some new ideas, please let me know!

Mark

6 Replies

@pmi --

I don't use Django/mod_wsgi. I did a search on the package libapache2-mod-wsgi-py3 in my installation repository. Here's the results (for Debian 10 "Buster"…and, most likely, recent versions of Ubuntu):

Package: libapache2-mod-wsgi-py3
Source: mod-wsgi
Version: 4.6.5-1
Installed-Size: 280
Maintainer: Debian Python Modules Team python-modules-team@lists.alioth.debian.org
Architecture: amd64
Provides: httpd-wsgi
Depends: apache2-api-20120211, apache2-bin (>= 2.4.16), python3 (>= 3.7), python3 (<< 3.8), libc6 (>= 2.14), libpython3.7 (>= 3.7.0)

Please note the required dependencies…python 3.6.6 is not listed. I don't know enough about your issue to comment in any more depth than this.

-- sw

@stevewi --

Thanks for the information. I will try creating a new virtualenv with python3.7. I hope my app will work, as I have been developing it with python 3.6.6.

Mark

Well, now I cannot compile dlib with python 3.7.

dlib warning: ‘int PyThread_create_key()’ is deprecated [-Wdeprecated-declarations]

This warning kills the dlib build.

Can't find any solutions to this problem, so I can't run my django project on python 3.7.

Mark

@pmi --

I dunno what to tell you… I don't know anything about python{2,3} or your app/service. I just relayed what I found.

However, the first thing I would try is to compile it without this warning enabled (-Wdeprecated-declarations) and see how far you get. How far you get is going to depend on if you actually use the deprecated declaration in your app/service. If you don't use it (and none of the other stuff your app/service depends on uses it), you're probably golden. However, I'm not offering any guarantees and you take my advice at your own risk.

-- sw

@stevewi --

Thanks for the advice. I did some research, and it seems that as of Python 3.7, the PyThread_* API was deprecated and superceded by the Thread Specific Storage API.

Details from Python documentation:
https://docs.python.org/3/c-api/init.html#thread-specific-storage-tss-api
https://www.python.org/dev/peps/pep-0539/

Compiling against Python 3.7 will produce numerous deprecation warnings for every file that includes pybind11 headers and dlib uses pybind11. I tried using the latest dlib, and it still has this issue.

Since it is just warnings, I am not sure why the whole make/install process for dlib fails. I would think the warnings would be produced, but not cause a catastrophic failure. Unless you are saying the compiling with the warnings off will somehow allow the make/install process complete?

I am going to take another route and see if I can compile mod_wsgi against Python 3.6.6. Perhaps I will get lucky.

Mark

@pmi --

You write:

Unless you are saying the compiling with the warnings off will somehow allow the make/install process complete?

That was my assumption, yes.

You also write:

I am going to take another route and see if I can compile mod_wsgi against Python 3.6.6. Perhaps I will get lucky.

That was going to be my next suggestion.

HOWEVER… You also need to be prepared for the eventuality that you may be completely out of gas with this too. You need to be prepared to (possibly) re-architect your app/service for (>=)Python 3.7.

You could also develop some kind of 3.6 -> proxy -> 3.7 mod_wsgi scheme. However, this would take time/effort and never be anything more than a giant kludge. Still, it may buy you some time while you plan/execute the re-architect operation mentioned above. You should never view something like this as a permanent part of your app/service.

-- sw

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct