vscode設置python3.7調試環境(已更新)


匯總系列:https://www.cnblogs.com/dunitian/p/4822808.html#ai

CentOS安裝Python3.7:https://www.cnblogs.com/dotnetcrazy/p/9360831.html

Update

2018-08-08pip 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) 的觸發器 ...


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM