配置Python远程开发环境前提
配置步骤
1.windows 10 开发机配置
win10 1809后支持ssh
ssh-keygen -t rsa -b 4096
#会显示生成到的目录C:Userszgx/.ssh/id_rsa
#生成本地私钥和公钥
#id_rsa和id_rsa.pub
2.Linux服务配置
将window开发机上生成的id_rsa.pub公钥文件内容追加到Linux上 /root/.ssh/authorized_keys
#windows上操作
scp C:Userszgx.sshid_rsa.pub [user]@[ip]:/root/.ssh/id_rsa.pub
#进虚机操作
cat /root/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys
现在实现了windows连接不需要密码
ssh [romote_ip]
...
3.vscode 扩展
a)vscode 安装拓展 Remote Developement
b)添加主机配置,并进行远程连接
具体配置如下
Host [remote_ip]
HostName [host_name]
User root
ForwardAgent yes
# IdentityFile C:Userszgx.sshid_rsa
配置完成后就可以连接了,需要选择Linux平台
4.Python侧配置
a)安装Python拓展,就是这玩意
b)打开某个项目文件夹,建议Python虚拟环境配置
pip install virtualenv
virtualenv venv
选择虚拟环境
c)vscode设置Python头文件信息
文件->首选项->代码片段
修改配置
{
"HEADER":{
"prefix": "header",
"body": [
"#!/usr/bin/env python",
"# -*- encoding: utf-8 -*-",
"'''",
"@File : $TM_FILENAME",
"@Time : $CURRENT_YEAR/$CURRENT_MONTH/$CURRENT_DATE $CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND",
"@Author : Rao Guangxiang ",
"@Version : 1.0",
"@Contact : raogx.vip@hotmail.com",
"@License : (C)Copyright 2017-2018, Liugroup-NLPR-CASIA",
"@Desc : None",
"'''",
"",
"# here put the import lib",
"$0"
],
}
}
参考资料
[1]https://www.cnblogs.com/iSuwei/p/12093612.html
[2]https://blog.csdn.net/u011809553/article/details/80937624
[3]https://blog.csdn.net/jinxiaonian11/article/details/83542696