前言
经常性需要linux环境跑各种python程序,环境老是要安装调试的麻烦 直接就远程开发,而且只有3.7以上版本python 才能使用vscode调试
环境
python3.7
vscode
vscode plugin -remote-ssh插件
vscode plugin-python插件
centos7.3
过程
编译python3
# 第三方库 yum install libffi-devel yum -y install zlib-devel python-devel gcc libffi-devel tk-devel libpcap-devel bzip2-devel db4-devel xz-devel openssl-devel ncurses-devel patch readline-devel gdbm-devel sqlite-devel #重新编译python 使用ssl ./configure --prefix=/usr/local/python3 --with-ssl # 安装 make && make install #添加python3的软链接 ln -s /usr/local/python3/bin/python3.7 /usr/bin/python3 #添加pip3的软链接 ln -s /usr/local/python3/bin/pip3.7 /usr/bin/pip3
Vscode安装及远程插件安装
安装python插件
Python
Python Extension Pack
安装好后也不需要Launch.json和task.json
添加断点
直接Run和F5 Debug
效果
常见问题
Debug时,报错No module named ‘_ctypes‘ 导致Debug不能
# 第三方库 yum install libffi-devel yum -y install zlib-devel python-devel gcc libffi-devel tk-devel libpcap-devel bzip2-devel db4-devel xz-devel openssl-devel ncurses-devel patch readline-devel gdbm-devel sqlite-devel #重新编译python 使用ssl ./configure --prefix=/usr/local/python3 --with-ssl # 安装 make && make install