You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用uWSGI启动Django项目时遇python_plugin.so加载失败等错误

Fixing uWSGI + Django Issues on MacBook Pro 2015

Hey there! Let's work through the two main errors you're hitting when trying to start your Django project with uWSGI.

1. Resolving the python_plugin.so Not Found Error

The first error !!! UNABLE to load uWSGI plugin: dlopen(./python_plugin.so, 10): image not found !!! happens because uWSGI can't locate the Python plugin, or you might not even need to specify it if you're using a virtual environment. Here's how to fix it:

  • Reinstall uWSGI in your virtual environment (most reliable fix):
    First, uninstall the existing uWSGI instance:

    pip uninstall uwsgi
    

    Then reinstall it within your activated virtual environment:

    source venv/bin/activate
    pip install uwsgi
    

    When you install uWSGI via pip in your venv, it compiles against your virtual environment's Python version, so you won't need to add the --plugin python flag anymore. Your simplified command will be:

    uwsgi --http :8000 --module myProject.wsgi
    
  • If you still need to specify the plugin path (less common):
    If for some reason you have to use the --plugin flag, find the actual path to the Python plugin file. You can locate it by running:

    find /path/to/venv -name "python_plugin.so"
    

    Then update your uWSGI command to use the full path:

    uwsgi --http :8000 --plugin /path/to/python_plugin.so --module myProject.wsgi
    

2. Fixing the AppRegistryNotReady: Apps aren't loaded yet Error

This error occurs because you're importing modules that depend on Django models before Django has finished loading its apps. Looking at your traceback, the issue starts in wsgi.py where you import sio from your views, which in turn imports a User model.

Here's the fix:

  • Adjust the import order in your wsgi.py:
    Your wsgi.py should first initialize Django's WSGI application, then import any modules that rely on Django models. Update it to look like this:
    import os
    from django.core.wsgi import get_wsgi_application
    
    # Set the Django settings module
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myProject.settings')
    
    # Initialize Django's application first
    application = get_wsgi_application()
    
    # Now import the sio module (after Django is ready)
    from admin_website_chat.views import sio
    
    By moving the import of sio after application = get_wsgi_application(), you ensure Django has fully loaded all apps and models before trying to access them.

Putting It All Together

After making these changes, activate your virtual environment again and run the simplified uWSGI command:

source venv/bin/activate
uwsgi --http :8000 --module myProject.wsgi

This should resolve both errors and get your Django project running with uWSGI.

内容的提问来源于stack exchange,提问作者sof-03

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 06:17:33