Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
326 views
in Technique[技术] by (71.8m points)

python - 500 internal server error when editing files on ubuntu server(No Module named Django)

I had my website running normally not until I made a few changes in the views.py and one of the templates file. Then I had this Werid error, "500 Internal Server Error", and when I changed the error logs. I saw the error.

Error Logs

(venv) root@vps-e47d7ac6:/home/ubuntu/app# sudo tail /var/log/apache2/error.log
[Tue Jan 26 07:40:03.581363 2021] [wsgi:error] [pid 18182:tid 140673103349504] [remote 197.210.227.43:50689] Traceback (most recent call last):
[Tue Jan 26 07:40:03.581405 2021] [wsgi:error] [pid 18182:tid 140673103349504] [remote 197.210.227.43:50689]   File "/var/www/app/station/asgi.py", line 12, in <module>
[Tue Jan 26 07:40:03.581414 2021] [wsgi:error] [pid 18182:tid 140673103349504] [remote 197.210.227.43:50689]     from django.core.asgi import get_asgi_application
[Tue Jan 26 07:40:03.581446 2021] [wsgi:error] [pid 18182:tid 140673103349504] [remote 197.210.227.43:50689] ImportError: No module named 'django'
[Tue Jan 26 07:40:04.348655 2021] [wsgi:error] [pid 18182:tid 140673220962048] [remote 197.210.54.234:55809] mod_wsgi (pid=18182): Target WSGI script '/var/www/app/station/asgi.py' cannot be loaded as Python module.
[Tue Jan 26 07:40:04.348789 2021] [wsgi:error] [pid 18182:tid 140673220962048] [remote 197.210.54.234:55809] mod_wsgi (pid=18182): Exception occurred processing WSGI script '/var/www/app/station/asgi.py'.
[Tue Jan 26 07:40:04.348939 2021] [wsgi:error] [pid 18182:tid 140673220962048] [remote 197.210.54.234:55809] Traceback (most recent call last):
[Tue Jan 26 07:40:04.348978 2021] [wsgi:error] [pid 18182:tid 140673220962048] [remote 197.210.54.234:55809]   File "/var/www/app/station/asgi.py", line 12, in <module>
[Tue Jan 26 07:40:04.348987 2021] [wsgi:error] [pid 18182:tid 140673220962048] [remote 197.210.54.234:55809]     from django.core.asgi import get_asgi_application
[Tue Jan 26 07:40:04.349017 2021] [wsgi:error] [pid 18182:tid 140673220962048] [remote 197.210.54.234:55809] ImportError: No module named 'django'

I noticed that the version of pip i was using is very old around 8.9.0, so i upgraded it to the laste one 20.0.2 but i was not able to use pip again to install packages, what could be wrong please

I ran the following commands to fix my pip issue ```sudo apt update```, ```sudo apt install python-pip``` and when i ran the ```pip --version``` I got the error below.

(venv) root@vps-e47d7ac6:/home/ubuntu/app# pip install -r requirements.txt Traceback (most recent call last): File "/home/ubuntu/venv/bin/pip", line 7, in from pip._internal.cli.main import main File "/home/ubuntu/venv/lib/python3.5/site-packages/pip/_internal/cli/main.py", line 60 sys.stderr.write(f"ERROR: {exc}") ^ SyntaxError: invalid syntax

question from:https://stackoverflow.com/questions/65897533/500-internal-server-error-when-editing-files-on-ubuntu-serverno-module-named-dj

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...