在将 Django 项目上传到 droplet 后,我意识到我正在使用 3.5 不支持的新功能,例如 f' 字符串,我继续使用本指南安装 Python 3.6.3:
https://www.rosehosting.com/blog/how-to-install-python-3-6-on-ubuntu-16-04/
看起来安装成功了。当我在控制台上写“python3 -V”时,它会回复 Python 3.6.3。
当输入“pip freeze”时,它会出现 Django==2.0.4 。
输入“python3 manage.py makemigrations”时出现问题,我收到此错误:
Traceback (most recent call last):
File "manage.py", line 8, in <module>
from django.core.management import execute_from_command_line
ModuleNotFoundError: No module named 'django'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "manage.py", line 14, in <module>
) from exc
ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?
最佳答案
最有可能,pip
指的是 Python 2;您可能需要使用 pip3
.
关于python - 在 digitalocean Ubuntu 16.04 中安装新版本的 Python 后无法运行 Django 控制台,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50326090/