目录
一.查询Django最新版本号
最新版本为3.0.7
二.安装Django3.0.7根据官网提示使用pip安装,在之前教程中,我们已经安装了Python3.8 并同时安装了pip3。
接下来我们使用终端开始安装Django3.0.7
打开终端输入如下命令:
#先查看一下pip版本
[email protected] ~ % pip -V
pip 19.2.3 from /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/pip (python 3.8)
#开始安装Django3.0.7
[email protected] ~ % pip install Django==3.0.7
Collecting Django==3.0.7
Downloading https://files.pythonhosted.org/packages/5c/63/6d7efecbf3f06db8c6577950a24a191e55cadf7cda4d7fe6976206c886dd/Django-3.0.7-py3-none-any.whl (7.5MB)
|████████████████████████████████| 7.5MB 101kB/s
Collecting asgiref~=3.2 (from Django==3.0.7)
Downloading https://files.pythonhosted.org/packages/d5/eb/64725b25f991010307fd18a9e0c1f0e6dff2f03622fc4bcbcdb2244f60d6/asgiref-3.2.10-py3-none-any.whl
Collecting sqlparse>=0.2.2 (from Django==3.0.7)
Downloading https://files.pythonhosted.org/packages/85/ee/6e821932f413a5c4b76be9c5936e313e4fc626b33f16e027866e1d60f588/sqlparse-0.3.1-py2.py3-none-any.whl (40kB)
|████████████████████████████████| 40kB 77kB/s
Collecting pytz (from Django==3.0.7)
Downloading https://files.pythonhosted.org/packages/4f/a4/879454d49688e2fad93e59d7d4efda580b783c745fd2ec2a3adf87b0808d/pytz-2020.1-py2.py3-none-any.whl (510kB)
|████████████████████████████████| 512kB 87kB/s
Installing collected packages: asgiref, sqlparse, pytz, Django
Successfully installed Django-3.0.7 asgiref-3.2.10 pytz-2020.1 sqlparse-0.3.1
#这个提示说明你的pip不是最新版本。可以按提示更新。不用管它,能用就行。
WARNING: You are using pip version 19.2.3, however version 20.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
[email protected] ~ %
安装成功
三.验证Django是否安装成功
查看一下Django3的安装路径,只是看一下。
[email protected] ~ % python -c "import django; print(django.__path__)" ['/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django'] [email protected] ~ %
验证安装是否成功,并输出Django3版本号
#运行python [email protected] ~ % python Python 3.8.3 (v3.8.3:6f8c8320e9, May 13 2020, 16:29:34) [Clang 6.0 (clang-600.0.57)] on darwin Type "help", "copyright", "credits" or "license" for more information.
#导入django包后回车,如果不报错证明安装成功
>>> import django
#打印Django版本号
>>> print(django.__version__)
#版本号为3.0.7
3.0.7
#退出
>>> exit()
[email protected] ~ %
至此Django3.0.7安装成功