问题遇到的现象和发生背景
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'