-
Notifications
You must be signed in to change notification settings - Fork 270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ImportError: cannot import name 'encodings' from 'psycopg2._psycopg' (again) #915
Comments
Try changing to use:
In other words, add within the
I don't know why but some versions of That extra directive will force the Python WSGI application to run in the main interpreter context of the mod_wsgi daemon process instead of a sub interpreter context. |
That did the trick indeed ! thanks a million :) for the record the app was working just fine in fedora 39, and I ran into this when upgrading to fedora41 here are a few possibly relevant changes:
|
I've encountered exactly the same problem. Severity of this bug is quite serious. Essentially, every WSGI application using Django framework stopped working in Fedora 41. To complicate things even more, the error above is masked by another exception there, so I had to spend some time to uncover the real problem. To reproduce it, you just need to have any simple WSGI app that does Although the workaround with Running a WSGI app with
However, running the same WSGI application with the same environment variable in Fedora 41 produces something different:
As you can see, during initialising basic exceptions, So, I've added
If you search for This happens only when run as a WSGI app, I found no other way to reproduce this behaviour outside of WSGI. I've tried to write a simple C wrapper that mimicks WSGI behaviour, but I think, I've oversimplified this behaviour, so it didn't help me to reproduce this error. Hence, I'm pretty sure that this is a problem either with |
Updating both I've built There is already |
Key thing I mentioned above is that without the Am going to call in @vstinner and @tiran to see if they have any ideas. Unfortunately I am about to go on trip and will have no ability to work on code when away, so if this needs an urgent resolution it needs to all be sorted out by Sunday. |
BTW, don't know if it makes a difference or not, but in 5.0.1 there was a switch to using PyConfig API. I am not sure if one can build 5.0.0 on Python 3.13 due to other API removals. Also note that cannot test with |
5.0.0 was built for Fedora 41 using this patch: This patch is not (obviously) applied for building 5.0.2, and installing 5.0.2 doesn't make any difference regarding this issue, as I mentioned above. Upgrading both |
So the |
To debug the issue, you might try to import $ ./python
>>> import _testcapi
>>> _testcapi.run_in_subinterp("print('Hello')")
Hello
0 It's likely that there are import machinery changes related to subinterpreters between Python 3.12 and Python 3.13. Or maybe the |
this issue resonates with #753
however I have not been able to solve my problem from that issue, so here is a new one
in my case I have a plain fedora41 box freshly installed, trying to run an application that was working fine within fedora40, but that fails in this new environment
I have python3 and python3-psycopg2 installed through dnf from fedora
and as far as the terminal, this works fine, in that I can do
python -c "import psycopg2"
however when invoked through wsgi I am getting the error quoted in the title, and more specifically
the apache config reads
the puzzling thing is that again this was working fine within fedora40 - which was using python-3.12 instead of 3.13 here, but well that does not seem too relevant..
there is no virtualenv in this box, just one plain system python install
let me know if I can make anything clearer
The text was updated successfully, but these errors were encountered: