CentOS8 Server with GUI 安装会自动安装上python3,pip3
安装Django
python3 -m pip install Django
注意,在CentOS8下执行python是要打上版本号的,即:python3
WARNING: Running pip install with root privileges is generally not a good idea. Try `__main__.py install --user` instead.
Collecting Django
Downloading https://files.pythonhosted.org/packages/a9/4f/8a247eee2958529a6a805d38fbacd9764fd566462fa0016aa2a2947ab2a6/Django-3.0.5-py3-none-any.whl (7.5MB)
100% |████████████████████████████████| 7.5MB 41kB/s
Collecting sqlparse>=0.2.2 (from Django)
Downloading https://files.pythonhosted.org/packages/85/ee/6e821932f413a5c4b76be9c5936e313e4fc626b33f16e027866e1d60f588/sqlparse-0.3.1-py2.py3-none-any.whl (40kB)
100% |████████████████████████████████| 40kB 48kB/s
Requirement already satisfied: pytz in /usr/lib/python3.6/site-packages (from Django)
Collecting asgiref~=3.2 (from Django)
Downloading https://files.pythonhosted.org/packages/68/00/25013f7310a56d17e1ab6fd885d5c1f216b7123b550d295c93f8e29d372a/asgiref-3.2.7-py2.py3-none-any.whl
Installing collected packages: sqlparse, asgiref, Django
Successfully installed Django-3.0.5 asgiref-3.2.7 sqlparse-0.3.1
安装完毕之后测试以下django是否能正确运行。
首先进入python3提示符状态:
[root@izt4n8avg]# python3
Python 3.7.4 (default, May 2 2020, 15:23:46)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> print (django.get_version())
3.0.5