{"id":5041,"library":"pyuwsgi","title":"pyuwsgi","description":"pyuwsgi is the official Python package providing the uWSGI server, a fast, self-healing, and developer-friendly application server for web applications. It serves as a glue layer between Python web applications (WSGI) and various protocols like HTTP, SCGI, and FastCGI. The current stable version is 2.0.30.post1, and it generally follows the release cadence of the underlying uWSGI C core.","status":"active","version":"2.0.30.post1","language":"en","source_language":"en","source_url":"https://github.com/unbit/uwsgi","tags":["wsgi","web server","http","application server","deployment"],"install":[{"cmd":"pip install pyuwsgi","lang":"bash","label":"Install pyuwsgi"}],"dependencies":[],"imports":[{"note":"The `uwsgi` module is primarily for applications *already running within* a uWSGI instance to interact with server internals (e.g., logging, caching). It is NOT used to start or manage the uWSGI server itself from arbitrary Python code; uWSGI is run as an executable.","wrong":"from pyuwsgi import uwsgi_server","symbol":"uwsgi","correct":"import uwsgi"}],"quickstart":{"code":"import os\n\ndef application(environ, start_response):\n    # A minimal WSGI application\n    status = '200 OK'\n    headers = [('Content-type', 'text/plain')]\n    start_response(status, headers)\n    return [b\"Hello from uWSGI!\"]\n\n# To run this, save it as `app.py` and then run:\n# uwsgi --http :8000 --wsgi-file app.py --callable application\n# Or, if `uwsgi` executable isn't in your PATH:\n# python -m uwsgi --http :8000 --wsgi-file app.py --callable application","lang":"python","description":"This quickstart demonstrates how to create a simple WSGI application and run it using the `uwsgi` executable provided by the `pyuwsgi` package. The server listens on HTTP port 8000 and serves the 'application' callable from `app.py`."},"warnings":[{"fix":"Run uWSGI as a command-line executable (e.g., `uwsgi --ini myapp.ini` or `python -m uwsgi ...`) and point it to your WSGI application.","message":"pyuwsgi provides the uWSGI server *executable*, not a Python library to import for server management. Attempting to `import uwsgi` to start or manage the server from your application code will not work as expected; the `uwsgi` module is for applications *already running within* a uWSGI instance to interact with the server environment (e.g., `uwsgi.log()`, `uwsgi.cache_get()`).","severity":"gotcha","affected_versions":"All"},{"fix":"Ensure you have the necessary build tools and Python development libraries installed for your operating system before running `pip install`.","message":"Installation via `pip install pyuwsgi` often requires C compilers (like `gcc`) and Python development headers (e.g., `python3-dev` on Debian/Ubuntu, `build-essential`, or Xcode Command Line Tools on macOS) to be present on the system, as `pyuwsgi` is a C extension. Without these, `pip` might fail to compile and install the package.","severity":"gotcha","affected_versions":"All"},{"fix":"Familiarize yourself with uWSGI's configuration options and consider using `.ini` files for deployment (e.g., `uwsgi --ini myapp.ini`).","message":"uWSGI offers a vast array of configuration options, typically managed via `.ini` files. While command-line arguments are suitable for simple cases, production deployments almost universally use `.ini` files for clarity, reusability, and advanced features (e.g., multiple processes, logging, master/worker management).","severity":"gotcha","affected_versions":"All"},{"fix":"Deploy uWSGI behind a dedicated reverse proxy server to offload network-facing tasks and enhance performance/security.","message":"For robust production environments, it's highly recommended to run uWSGI behind a reverse proxy server like Nginx or Caddy. The reverse proxy can handle static file serving, SSL/TLS termination, request buffering, and load balancing more efficiently and securely than uWSGI directly.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}