勤勉敦敏 2022-01-22 11:29 采纳率: 82.8%
浏览 561
已结题

django配置uwsgi提示ModuleNotFoundError: No module named 'django' unable to load app 0 (mountpoint='')

问题遇到的现象和发生背景

ubuntu没有用虚拟环境,直接安装
使用uwsgi --http :8000 --chdir /home/cc/web1 --module web1.wsgi启动正常
用uwsgi.ini启动报错

*** Operational MODE: preforking ***
Traceback (most recent call last):
  File "/home/cc/web1/./web1/wsgi.py", line 13, in <module>
    from django.core.wsgi import get_wsgi_application
ModuleNotFoundError: No module named 'django'
unable to load app 0 (mountpoint='') (callable not found or import error)
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 2323)
spawned uWSGI worker 1 (pid: 2326, cores: 1)
spawned uWSGI worker 2 (pid: 2327, cores: 1)
spawned uWSGI worker 3 (pid: 2328, cores: 1)
spawned uWSGI worker 4 (pid: 2329, cores: 1)
spawned uWSGI worker 5 (pid: 2330, cores: 1)
spawned uWSGI http 1 (pid: 2331)
--- no python application found, check your startup logs for errors ---

问题相关代码,请勿粘贴截图
运行结果及报错内容

单独运行wsgi.py

cc@ubuntu:~/web1/web1$ python wsgi.py
['/home/cc/web1/web1', '/usr/lib/python38.zip', '/usr/lib/python3.8', '/usr/lib/python3.8/lib-dynload', '/home/cc/.local/lib/python3.8/site-packages', '/usr/local/lib/python3.8/dist-packages', '/usr/lib/python3/dist-packages']
Traceback (most recent call last):
  File "wsgi.py", line 18, in <module>
    application = get_wsgi_application()
  File "/home/cc/.local/lib/python3.8/site-packages/django/core/wsgi.py", line 12, in get_wsgi_application
    django.setup(set_prefix=False)
  File "/home/cc/.local/lib/python3.8/site-packages/django/__init__.py", line 19, in setup
    configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
  File "/home/cc/.local/lib/python3.8/site-packages/django/conf/__init__.py", line 84, in __getattr__
    self._setup(name)
  File "/home/cc/.local/lib/python3.8/site-packages/django/conf/__init__.py", line 71, in _setup
    self._wrapped = Settings(settings_module)
  File "/home/cc/.local/lib/python3.8/site-packages/django/conf/__init__.py", line 179, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'web1'


我的解答思路和尝试过的方法
我想要达到的结果
  • 写回答

1条回答 默认 最新

  • 唯羽 2022-01-22 13:52
    关注

    python的绝对路径是哪?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 1月30日
  • 已采纳回答 1月22日
  • 修改了问题 1月22日
  • 创建了问题 1月22日

悬赏问题

  • ¥20 keepalive配置业务服务双机单活的方法。业务服务一定是要双机单活的方式
  • ¥50 关于多次提交POST数据后,无法获取到POST数据参数的问题
  • ¥15 win10,这种情况怎么办
  • ¥15 如何在配置使用Prettier的VSCode中通过Better Align插件来对齐等式?(相关搜索:格式化)
  • ¥100 在连接内网VPN时,如何同时保持互联网连接
  • ¥15 MATLAB中使用parfor,矩阵Removal的有效索引在parfor循环中受限制
  • ¥20 Win 10 LTSC 1809版本如何无损提升到20H1版本
  • ¥50 win10 LTSC 虚拟键盘不弹出
  • ¥30 微信小程序请求失败,网页能正常带锁访问
  • ¥15 Matlab求解微分方程,如何用fish2d进行预优?