在学习Django的时候,开始使用的是centos,但是在做的时候,有一个错误,换一个ubuntu环境,安装一个pycharm进行学习开发
1. 下载PyCharm安装包
进入官网下载包
下载后
2. 安装PyCharm
2.1 解压文件
root@darren-virtual-machine:/usr/local/src# cd /root/Downloads/、
root@darren-virtual-machine:~/Downloads# tar -xf pycharm-professional-2019.3.4.tar.gz
root@darren-virtual-machine:~/Downloads# ll
drwxr-xr-x 10 root root 4096 4月 4 20:26 pycharm-2019.3.4/
-rw-r--r-- 1 root root 513944449 4月 4 20:03 pycharm-professional-2019.3.4.tar.gz
root@darren-virtual-machine:~/Downloads# cd pycharm-2019.3.4/
root@darren-virtual-machine:~/Downloads/pycharm-2019.3.4# ll
drwxr-xr-x 2 root root 4096 4月 4 20:26 bin/
-rw-r--r-- 1 root root 14 3月 18 16:09 build.txt
drwxr-xr-x 2 root root 4096 4月 4 20:26 debug-eggs/
drwxr-xr-x 2 root root 4096 4月 4 20:26 help/
drwxr-xr-x 3 root root 4096 4月 4 20:26 index/
-rw-r--r-- 1 root root 1898 3月 18 16:27 Install-Linux-tar.txt
drwxr-xr-x 7 root root 4096 4月 4 20:26 jbr/
drwxr-xr-x 4 root root 12288 4月 4 20:26 lib/
drwxr-xr-x 2 root root 4096 4月 4 20:26 license/
drwxr-xr-x 52 root root 4096 4月 4 20:26 plugins/
-rw-r--r-- 1 root root 373 3月 18 16:28 product-info.json
root@darren-virtual-machine:~/Downloads/pycharm-2019.3.4# cd bin/
root@darren-virtual-machine:~/Downloads/pycharm-2019.3.4/bin# ll
-rwxr-xr-x 1 root root 221 3月 18 16:27 format.sh*
-rwxr-xr-x 1 root root 26660 3月 18 16:27 fsnotifier*
-rwxr-xr-x 1 root root 32888 3月 18 16:27 fsnotifier64*
-rw-r--r-- 1 root root 10911 3月 18 16:27 idea.properties
-rwxr-xr-x 1 root root 296 3月 18 16:27 inspect.sh*
-rw-r--r-- 1 root root 39520 3月 18 16:27 libdbm64.so
-rw-r--r-- 1 root root 2322 3月 18 16:09 log.xml
-rwxr-xr-x 1 root root 410 3月 18 16:27 printenv.py*
-rw-r--r-- 1 root root 538 3月 18 16:27 pycharm64.vmoptions
-rw-r--r-- 1 root root 10281 3月 18 16:27 pycharm.png
-rwxr-xr-x 1 root root 7384 3月 18 16:27 pycharm.sh*
-rw-r--r-- 1 root root 3565 3月 18 16:09 pycharm.svg
-rw-r--r-- 1 root root 546 3月 18 16:27 pycharm.vmoptions
-rwxr-xr-x 1 root root 808 3月 18 16:27 restart.py*
2.2 安装
root@darren-virtual-machine:~/Downloads/pycharm-2019.3.4/bin# sh ./pycharm.sh
出现Complete-Installation提示框,如图5,如果需要导入之前安装版本的配置的话,就选第一个,没有就选第二个。所以这里选第二个,直接点OK,
弹出 PyCharm Privary Policy Agreement,隐私政策协议框,点击Continue
选择跳过
先使用免费30的,后面再激活
安装完成
2.3 创建桌面快捷方式
root@darren-virtual-machine:~/Desktop# touch pycharm.desktop
root@darren-virtual-machine:~/Desktop# vim pycharm.desktop
[Desktop Entry]
Encoding=UTF-8
Name=pycharm
Exec=sh /root/Downloads/pycharm-2019.3.4/bin/pycharm.sh
Icon=/root/Downloads/pycharm-2019.3.4/bin/pycharm.png
Info="Spark"
Terminal=false
Type=Application
StartupNotify=true
root@darren-virtual-machine:~/Desktop# chmod 700 pycharm.desktop
点击桌面图标文件,并添加信任,结果如下
三 ubuntu安装python3
3.1 安装python3
root@darren-virtual-machine:~# apt update
root@darren-virtual-machine:~# apt -y upgrade
root@darren-virtual-machine:~# python3 -V
Python 3.6.9
3.2 安装pip
root@darren-virtual-machine:~# apt install -y python3-pip
root@darren-virtual-machine:~# pip3 -V
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)
3.3 升级
root@darren-virtual-machine:~# python3 -m pip install --upgrade pip
Collecting pip
Downloading https://files.pythonhosted.org/packages/54/0c/d01aa759fdc501a58f431eb594a17495f15b88da142ce14b5845662c13f3/pip-20.0.2-py2.py3-none-any.whl (1.4MB)
100% |████████████████████████████████| 1.4MB 498kB/s
Installing collected packages: pip
Found existing installation: pip 9.0.1
Not uninstalling pip at /usr/lib/python3/dist-packages, outside environment /usr
Successfully installed pip-20.0.2
四 创建一个django项目
4.1 下载django
命令行安装
root@darren-virtual-machine:~# pip3 install django
Collecting django
Downloading Django-3.0.5-py3-none-any.whl (7.5 MB)
|████████████████████████████████| 7.5 MB 2.3 MB/s
Collecting asgiref~=3.2
Downloading asgiref-3.2.7-py2.py3-none-any.whl (19 kB)
Requirement already satisfied: pytz in /usr/lib/python3/dist-packages (from django) (2018.3)
Collecting sqlparse>=0.2.2
Downloading sqlparse-0.3.1-py2.py3-none-any.whl (40 kB)
|████████████████████████████████| 40 kB 1.3 MB/s
Installing collected packages: asgiref, sqlparse, django
Successfully installed asgiref-3.2.7 django-3.0.5 sqlparse-0.3.1
使用pychrm安装
4.2 创建项目
命令行创建
root@darren-virtual-machine:/usr/local/bin# cd /root/PycharmProjects/
root@darren-virtual-machine:~/PycharmProjects# django-admin startproject mysite
root@darren-virtual-machine:~/PycharmProjects# ll
drwxr-xr-x 3 root root 4096 4月 4 22:11 mysite/
使用pychrm创建项目
root@darren-virtual-machine:~/PycharmProjects# ll
drwxr-xr-x 3 root root 4096 4月 4 22:11 mysite/
drwxr-xr-x 6 root root 4096 4月 4 22:20 mysite2/
root@darren-virtual-machine:~/PycharmProjects# tree mysite2
mysite2
├── app01
│ ├── admin.py
│ ├── apps.py
│ ├── __init__.py
│ ├── migrations
│ │ └── __init__.py
│ ├── models.py
│ ├── tests.py
│ └── views.py
├── manage.py
├── mysite2
│ ├── asgi.py
│ ├── __init__.py
│ ├── __pycache__
│ │ ├── __init__.cpython-36.pyc
│ │ └── settings.cpython-36.pyc
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
└── templates
项目创建成功