您的位置:首页 > 编程语言 > Python开发

vscode设置python3.7调试环境(已更新)

2018-05-27 13:09 1186 查看

汇总系列:https://www.cnblogs.com/dunitian/p/4822808.html#ai

Update

2018-08-08:pip install [--user] rope :让Python对象支持批量重命名(eg:Ctrl+R+R)

 

独立安装python3的:

用户设置里面添加一下python3的路径即可

附录:

如果先安装Anaconda,再通过anaconda安装VSCode则不用管环境配置(会配置好),如果先安装vscode就自己配置下环境吧:

如果没配置你自己配置一下,以Linux来说:(先查看路径,再配置

 扩充(配置规范提示格式化):

命令参考:pip install [--user] xxx

规范化提示:pycodestyle or flake8(旧名字)

代码格式化:yapf or autopep8 

VSCode配置参考:(Conda默认安装了pycodestyle

附录:安装本地开发环境Python3.7

sudo apt-get install python3.7

sudo apt-get install python3.7-dbg

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

sudo python3.7 get-pip.py

sudo pip3.7 install pycodestyle
sudo pip3.7 install yapf

VSCode配置文件:

// 设置Python的路径
"python.pythonPath": "python3.7",
// "python.pythonPath": "/home/dnt/anaconda3/bin/python",
// 设置Python的代码格式化
"python.formatting.provider": "yapf",
// 设置Python的代码检查
"python.linting.flake8Path": "pycodestyle",
"python.linting.flake8Enabled": true,

sudo apt-get install python3.7
正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
将会同时安装下列软件:
libpython3.7-minimal libpython3.7-stdlib python3.7-minimal
建议安装:
python3.7-venv python3.7-doc
下列【新】软件包将被安装:
libpython3.7-minimal libpython3.7-stdlib python3.7 python3.7-minimal
升级了 0 个软件包,新安装了 4 个软件包,要卸载 0 个软件包,有 0 个软件包未被升级。
需要下载 4,011 kB 的归档。
解压缩后会消耗 22.8 MB 的额外空间。
您希望继续执行吗? [Y/n] y
获取:1 http://mirrors.ustc.edu.cn/ubuntu bionic/universe amd64 libpython3.7-minimal amd64 3.7.0~b3-1 [544 kB]
获取:2 http://mirrors.ustc.edu.cn/ubuntu bionic/universe amd64 python3.7-minimal amd64 3.7.0~b3-1 [1,563 kB]
获取:3 http://mirrors.ustc.edu.cn/ubuntu bionic/universe amd64 libpython3.7-stdlib amd64 3.7.0~b3-1 [1,685 kB]
获取:4 http://mirrors.ustc.edu.cn/ubuntu bionic/universe amd64 python3.7 amd64 3.7.0~b3-1 [219 kB]
已下载 4,011 kB,耗时 6秒 (691 kB/s)
正在选中未选择的软件包 libpython3.7-minimal:amd64。
(正在读取数据库 ... 系统当前共安装有 205966 个文件和目录。)
正准备解包 .../libpython3.7-minimal_3.7.0~b3-1_amd64.deb ...
正在解包 libpython3.7-minimal:amd64 (3.7.0~b3-1) ...
正在选中未选择的软件包 python3.7-minimal。
正准备解包 .../python3.7-minimal_3.7.0~b3-1_amd64.deb ...
正在解包 python3.7-minimal (3.7.0~b3-1) ...
正在选中未选择的软件包 libpython3.7-stdlib:amd64。
正准备解包 .../libpython3.7-stdlib_3.7.0~b3-1_amd64.deb ...
正在解包 libpython3.7-stdlib:amd64 (3.7.0~b3-1) ...
正在选中未选择的软件包 python3.7。
正准备解包 .../python3.7_3.7.0~b3-1_amd64.deb ...
正在解包 python3.7 (3.7.0~b3-1) ...
正在处理用于 mime-support (3.60ubuntu1) 的触发器 ...
正在处理用于 desktop-file-utils (0.23-1ubuntu3.18.04.1) 的触发器 ...
正在设置 libpython3.7-minimal:amd64 (3.7.0~b3-1) ...
正在设置 python3.7-minimal (3.7.0~b3-1) ...
正在处理用于 bamfdaemon (0.5.3+18.04.20180207.2-0ubuntu1) 的触发器 ...
Rebuilding /usr/share/applications/bamf-2.index...
正在处理用于 man-db (2.8.3-2) 的触发器 ...
正在处理用于 gnome-menus (3.13.3-11ubuntu1) 的触发器 ...
正在设置 libpython3.7-stdlib:amd64 (3.7.0~b3-1) ...
正在设置 python3.7 (3.7.0~b3-1) ...

sudo apt-get install python3.7-dbg

正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
将会同时安装下列软件:
libpython3.7-dbg
建议安装:
python3-gdbm-dbg python3-tk-dbg
下列【新】软件包将被安装:
libpython3.7-dbg python3.7-dbg
升级了 0 个软件包,新安装了 2 个软件包,要卸载 0 个软件包,有 0 个软件包未被升级。
需要下载 25.1 MB 的归档。
解压缩后会消耗 86.1 MB 的额外空间。
您希望继续执行吗? [Y/n] y
获取:1 http://mirrors.ustc.edu.cn/ubuntu bionic/universe amd64 libpython3.7-dbg amd64 3.7.0~b3-1 [10.9 MB]
获取:1 http://mirrors.ustc.edu.cn/ubuntu bionic/universe amd64 libpython3.7-dbg amd64 3.7.0~b3-1 [10.9 MB]
获取:2 http://mirrors.ustc.edu.cn/ubuntu bionic/universe amd64 python3.7-dbg amd64 3.7.0~b3-1 [14.2 MB]
已下载 23.4 MB,耗时 1分 55秒 (203 kB/s)
正在选中未选择的软件包 libpython3.7-dbg:amd64。
(正在读取数据库 ... 系统当前共安装有 206572 个文件和目录。)
正准备解包 .../libpython3.7-dbg_3.7.0~b3-1_amd64.deb ...
正在解包 libpython3.7-dbg:amd64 (3.7.0~b3-1) ...
正在选中未选择的软件包 python3.7-dbg。
正准备解包 .../python3.7-dbg_3.7.0~b3-1_amd64.deb ...
正在解包 python3.7-dbg (3.7.0~b3-1) ...
正在设置 libpython3.7-dbg:amd64 (3.7.0~b3-1) ...
正在处理用于 libc-bin (2.27-3ubuntu1) 的触发器 ...
正在设置 python3.7-dbg (3.7.0~b3-1) ...
正在处理用于 man-db (2.8.3-2) 的触发器 ...

安装pip:https://bootstrap.pypa.io/get-pip.py

sudo python3.7 get-pip.py
[sudo] dnt 的密码:
The directory '/home/dnt/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/dnt/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting pip
Downloading https://files.pythonhosted.org/packages/5f/25/e52d3f31441505a5f3af41213346e5b6c221c9e086a166f3703d2ddaf940/pip-18.0-py2.py3-none-any.whl (1.3MB)
100% |████████████████████████████████| 1.3MB 1.7MB/s
Collecting wheel
Downloading https://files.pythonhosted.org/packages/81/30/e935244ca6165187ae8be876b6316ae201b71485538ffac1d718843025a9/wheel-0.31.1-py2.py3-none-any.whl (41kB)
100% |████████████████████████████████| 51kB 1.0MB/s
Installing collected packages: pip, wheel
Successfully installed pip-18.0 wheel-0.31.1
dnt@MZY-PC:~/下载$ pip
pip pip3 pip3.7
dnt@MZY-PC:~/下载$ pip3.7 -V
pip 18.0 from /usr/local/lib/python3.7/dist-packages/pip (python 3.7)

sudo pip3.7 install pycodestyle
The directory '/home/dnt/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/dnt/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting pycodestyle
Downloading https://files.pythonhosted.org/packages/e5/c6/ce130213489969aa58610042dff1d908c25c731c9575af6935c2dfad03aa/pycodestyle-2.4.0-py2.py3-none-any.whl (62kB)
100% |████████████████████████████████| 71kB 144kB/s
Installing collected packages: pycodestyle
Successfully installed pycodestyle-2.4.0

sudo pip3.7 install yapf

The directory '/home/dnt/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/dnt/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting yapf
Downloading https://files.pythonhosted.org/packages/d5/ae/9d2e8f43f2ce467991c8310e361bbf4f1e1bf32afc6441b4e3416685b7ef/yapf-0.22.0-py2.py3-none-any.whl (166kB)
100% |████████████████████████████████| 174kB 495kB/s
Installing collected packages: yapf
Successfully installed yapf-0.22.0

可选安装:apt-get install python3.7-*

正在读取软件包列表... 完成
正在分析软件包的依赖关系树
正在读取状态信息... 完成
注意,根据Glob 'python3.7-*' 选中了 'python3.7-2to3'
注意,根据Glob 'python3.7-*' 选中了 'python3.7-tk'
注意,根据Glob 'python3.7-*' 选中了 'python3.7-venv'
注意,根据Glob 'python3.7-*' 选中了 'python3.7-distutils'
注意,根据Glob 'python3.7-*' 选中了 'python3.7-dbg'
注意,根据Glob 'python3.7-*' 选中了 'python3.7-dev'
注意,根据Glob 'python3.7-*' 选中了 'python3.7-doc'
注意,根据Glob 'python3.7-*' 选中了 'python3.7-gdbm'
注意,根据Glob 'python3.7-*' 选中了 'python3.7-minimal'
注意,根据Glob 'python3.7-*' 选中了 'python3.7-lib2to3'
注意,根据Glob 'python3.7-*' 选中了 'python3.7-examples'
注意,选中 'python3-distutils' 而非 'python3.7-distutils'
注意,选中 'python3-gdbm' 而非 'python3.7-gdbm'
注意,选中 'python3-lib2to3' 而非 'python3.7-lib2to3'
注意,选中 'python3-tk' 而非 'python3.7-tk'
python3-distutils 已经是最新版 (3.6.5-3)。
python3-distutils 已设置为手动安装。
python3-gdbm 已经是最新版 (3.6.5-3)。
python3-lib2to3 已经是最新版 (3.6.5-3)。
python3-lib2to3 已设置为手动安装。
python3.7-dbg 已经是最新版 (3.7.0~b3-1)。
python3.7-minimal 已经是最新版 (3.7.0~b3-1)。
python3.7-minimal 已设置为手动安装。
将会同时安装下列软件:
blt javascript-common libexpat1-dev libjs-jquery libjs-underscore
libpython3.7 libpython3.7-dev python-pip-whl tk8.6-blt2.5
建议安装:
blt-demo apache2 | lighttpd | httpd tix python3-tk-dbg
下列【新】软件包将被安装:
blt javascript-common libexpat1-dev libjs-jquery libjs-underscore
libpython3.7 libpython3.7-dev python-pip-whl python3-tk python3.7-dev
python3.7-doc python3.7-examples python3.7-venv tk8.6-blt2.5
升级了 0 个软件包,新安装了 14 个软件包,要卸载 0 个软件包,有 0 个软件包未被升级。
需要下载 16.6 MB 的归档。
解压缩后会消耗 78.0 MB 的额外空间。
您希望继续执行吗? [Y/n] y
获取:1 http://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 tk8.6-blt2.5 amd64 2.5.3+dfsg-4 [572 kB]
获取:2 http://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 blt amd64 2.5.3+dfsg-4 [4,944 B]
获取:3 http://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 javascript-common all 11 [6,066 B]
获取:4 http://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 libexpat1-dev amd64 2.2.5-3 [122 kB]
获取:5 http://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 libjs-jquery all 3.2.1-1 [152 kB]
获取:6 http://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 libjs-underscore all 1.8.3~dfsg-1 [59.9 kB]
获取:7 http://mirrors.ustc.edu.cn/ubuntu bionic/universe amd64 libpython3.7 amd64 3.7.0~b3-1 [1,507 kB]
获取:8 http://mirrors.ustc.edu.cn/ubuntu bionic/universe amd64 libpython3.7-dev amd64 3.7.0~b3-1 [2,361 kB]
获取:9 http://mirrors.ustc.edu.cn/ubuntu bionic-updates/universe amd64 python-pip-whl all 9.0.1-2.3~ubuntu1 [1,652 kB]
获取:10 http://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 python3-tk amd64 3.6.5-3 [100 kB]
获取:11 http://mirrors.ustc.edu.cn/ubuntu bionic/universe amd64 python3.7-dev amd64 3.7.0~b3-1 [501 kB]
获取:12 http://mirrors.ustc.edu.cn/ubuntu bionic/universe amd64 python3.7-doc all 3.7.0~b3-1 [9,171 kB]
获取:13 http://mirrors.ustc.edu.cn/ubuntu bionic/universe amd64 python3.7-examples all 3.7.0~b3-1 [422 kB]
获取:14 http://mirrors.ustc.edu.cn/ubuntu bionic/universe amd64 python3.7-venv amd64 3.7.0~b3-1 [6,036 B]
已下载 16.6 MB,耗时 24秒 (702 kB/s)
正在选中未选择的软件包 tk8.6-blt2.5。
(正在读取数据库 ... 系统当前共安装有 206847 个文件和目录。)
正准备解包 .../00-tk8.6-blt2.5_2.5.3+dfsg-4_amd64.deb ...
正在解包 tk8.6-blt2.5 (2.5.3+dfsg-4) ...
正在选中未选择的软件包 blt。
正准备解包 .../01-blt_2.5.3+dfsg-4_amd64.deb ...
正在解包 blt (2.5.3+dfsg-4) ...
正在选中未选择的软件包 javascript-common。
正准备解包 .../02-javascript-common_11_all.deb ...
正在解包 javascript-common (11) ...
正在选中未选择的软件包 libexpat1-dev:amd64。
正准备解包 .../03-libexpat1-dev_2.2.5-3_amd64.deb ...
正在解包 libexpat1-dev:amd64 (2.2.5-3) ...
正在选中未选择的软件包 libjs-jquery。
正准备解包 .../04-libjs-jquery_3.2.1-1_all.deb ...
正在解包 libjs-jquery (3.2.1-1) ...
正在选中未选择的软件包 libjs-underscore。
正准备解包 .../05-libjs-underscore_1.8.3~dfsg-1_all.deb ...
正在解包 libjs-underscore (1.8.3~dfsg-1) ...
正在选中未选择的软件包 libpython3.7:amd64。
正准备解包 .../06-libpython3.7_3.7.0~b3-1_amd64.deb ...
正在解包 libpython3.7:amd64 (3.7.0~b3-1) ...
正在选中未选择的软件包 libpython3.7-dev:amd64。
正准备解包 .../07-libpython3.7-dev_3.7.0~b3-1_amd64.deb ...
正在解包 libpython3.7-dev:amd64 (3.7.0~b3-1) ...
正在选中未选择的软件包 python-pip-whl。
正准备解包 .../08-python-pip-whl_9.0.1-2.3~ubuntu1_all.deb ...
正在解包 python-pip-whl (9.0.1-2.3~ubuntu1) ...
正在选中未选择的软件包 python3-tk:amd64。
正准备解包 .../09-python3-tk_3.6.5-3_amd64.deb ...
正在解包 python3-tk:amd64 (3.6.5-3) ...
正在选中未选择的软件包 python3.7-dev。
正准备解包 .../10-python3.7-dev_3.7.0~b3-1_amd64.deb ...
正在解包 python3.7-dev (3.7.0~b3-1) ...
正在选中未选择的软件包 python3.7-doc。
正准备解包 .../11-python3.7-doc_3.7.0~b3-1_all.deb ...
正在解包 python3.7-doc (3.7.0~b3-1) ...
正在选中未选择的软件包 python3.7-examples。
正准备解包 .../12-python3.7-examples_3.7.0~b3-1_all.deb ...
正在解包 python3.7-examples (3.7.0~b3-1) ...
正在选中未选择的软件包 python3.7-venv。
正准备解包 .../13-python3.7-venv_3.7.0~b3-1_amd64.deb ...
正在解包 python3.7-venv (3.7.0~b3-1) ...
正在设置 libjs-jquery (3.2.1-1) ...
正在设置 python-pip-whl (9.0.1-2.3~ubuntu1) ...
正在设置 libjs-underscore (1.8.3~dfsg-1) ...
正在处理用于 install-info (6.5.0.dfsg.1-2) 的触发器 ...
正在设置 python3.7-venv (3.7.0~b3-1) ...
正在设置 python3.7-examples (3.7.0~b3-1) ...
正在处理用于 libc-bin (2.27-3ubuntu1) 的触发器 ...
正在设置 tk8.6-blt2.5 (2.5.3+dfsg-4) ...
正在设置 libpython3.7:amd64 (3.7.0~b3-1) ...
正在处理用于 doc-base (0.10.8) 的触发器 ...
Processing 9 added doc-base files...
正在设置 libexpat1-dev:amd64 (2.2.5-3) ...
正在处理用于 man-db (2.8.3-2) 的触发器 ...
正在设置 javascript-common (11) ...
正在设置 python3.7-doc (3.7.0~b3-1) ...
正在设置 blt (2.5.3+dfsg-4) ...
正在设置 libpython3.7-dev:amd64 (3.7.0~b3-1) ...
正在设置 python3-tk:amd64 (3.6.5-3) ...
正在设置 python3.7-dev (3.7.0~b3-1) ...
正在处理用于 libc-bin (2.27-3ubuntu1) 的触发器 ...

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: