在 digitalocean Ubuntu 16.04 中安装新版本 Python 后无法 运行 Django 控制台

Not able to run a Django console after installing a new version of Python in digitalocean Ubuntu 16.04

将 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.