Comments (7)
Solution is that also need to set environment variable:
PYTHONIOENCODING=UTF-8
This is as well as LANG
and LC_ALL
.
from s2i-python-container.
I have written a blog about this problem before:
from s2i-python-container.
Hmmm, Gunicorn seems to fail to do the right thing even when these environment variables are set.
-- GLOBAL --
('en_US', 'UTF-8')
UTF-8
------------
-- REQUEST --
('en_US', 'UTF-8')
UTF-8
------------
[2016-12-06 20:20:30,923] ERROR in app: Exception on / [GET]
Traceback (most recent call last):
File "/opt/app-root/src/.local/lib/python2.7/site-packages/flask/app.py", line 1988, in wsgi_app
response = self.full_dispatch_request()
File "/opt/app-root/src/.local/lib/python2.7/site-packages/flask/app.py", line 1641, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/opt/app-root/src/.local/lib/python2.7/site-packages/flask/app.py", line 1544, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/opt/app-root/src/.local/lib/python2.7/site-packages/flask/app.py", line 1639, in full_dispatch_request
rv = self.dispatch_request()
File "/opt/app-root/src/.local/lib/python2.7/site-packages/flask/app.py", line 1625, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/opt/app-root/src/wsgi.py", line 13, in hello
print(u'\u292e')
UnicodeEncodeError: 'ascii' codec can't encode character u'\u292e' in position 0: ordinal not in range(128)
Additionally setting LC_LANG
doesn't help.
Spin up python
on the command line and works okay where as didn't before environment variables set. When I have run Python 3.5 app.py
with aiohttpd
application before problem was solved by environment variables. So Gunicorn is doing something nasty with its fiddling with stdout
or stderr
or need to provide other options to gunicorn
when run
is executing it.
from s2i-python-container.
This problem is only occurring with gunicorn
when it is run from the run
script triggered on container start. If you get an interactive shell using oc rsh
and in that run gunicorn
against a wsgi.py
file which prints out a problematic string on import it works fine. Similarly, if use oc debug
and run run
manually, works fine.
from s2i-python-container.
This goes beyond gunicorn
and seems to be an issue in general with Python 2.7 in a container where when not associated with a tty/interactive shell, default encoding doesn't get applied to stdout
and stderr
.
from s2i-python-container.
Closed via #167
from s2i-python-container.
for supervisor + gunicorn, can be config as below.
# other program config
[program:gunicorn]
command = gunicorn wsgi --bind 0.0.0.0:8000 --log-level error ...
environment = LANG=en_US.UTF-8,LC_ALL=en_US.UTF-8,PYTHONIOENCODING=UTF-8
#other program config
from s2i-python-container.
Related Issues (20)
- Streamlit Update HOT 1
- No Action Required !! Testing automation workflow HOT 1
- No Action Required !! Testing automation workflow HOT 4
- Remove verification of installed packages HOT 3
- 3.9 Readme Instructions unclear HOT 6
- Python 3.10 RHEL image missing in RHEL Container catalog? HOT 4
- Unable to build a Python image from scratch on MacOS HOT 1
- Python 3.9+ for Centos 7 docker images HOT 4
- tests: test case should fail early when the prepare function fails HOT 3
- Distgen errors HOT 11
- Incorrect py-3 image HOT 11
- Support gunicorn >=20.1.0 defaults (do not require APP_ environment variables) HOT 1
- Add RHEL images for Python 3.11 HOT 4
- ERROR: No matching distribution found for numpy==1.19.2 HOT 4
- Use PIP_INDEX_URL with pipenv HOT 1
- ubi9/python-311:latest is using python3.9-rpm HOT 2
- Publish arm64 images HOT 8
- rh-python38 failed on `'npm-virtualenv-uwsgi-test-app' run_s2i_build` & `'pin-pipenv-version-test-app' run_s2i_build` HOT 2
- python311-devel not found by microdnf in python 3.11 minimal EL8 and C9s variants HOT 1
- Documented pull example quay.io/sclorg/python-39-minimal isn't a valid URL HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from s2i-python-container.