一、本地安装Pycharm及Anaconda
1、Pycharm下载:https://download.jetbrains.8686c.com/python/pycharm-professional-2019.2.2.exe,按要求安装即可
2、Anaconda下载:https://repo.anaconda.com/archive/Anaconda3-2019.07-Windows-x86_64.exe,按照要求安装即可
注意:有时存在安装时选择了添加环境变量,在cmd仍然无法定位到anaconda的问题,此时将anaconda的路径添加到环境变量即可,网上有教程。
二、Pycharm建立Project
操作:FileNew ProjectCreate
三、Pycharm建立服务器Connection
1、操作:ToolsDeploymentConfigurationSFTPNew server name填写OK
2、配置如下:
#第一种情况,远程连接的服务器可以访问内网(host-accessible)
host:host-accessible-ip
port:host-accessible-port
username:host-accessible-username
password:host-accessible-password
root path:host-accessible定位的路径
#第二种情况,远程连接的服务器不能访问内网(host-inaccessible),通过SSH隧道技术建立中转服务器(host-accessible)
host:host-accessible-ip
port:host-accessible-port(SSH隧道建立的port,不是中转服务器port)
username:host-inaccessible-username
password:host-inaccessible-password
root path:host-inaccessible定位的路径
3、配置完成后可通过test connection测试远程连接
4、前文建立的本地Project(Local path)和远程服务器项目(Deployment path)连接
Local path:绝对路径;Deployment path:相对root path的路径
5、点击OK,完成远程连接
三、配置远程连接工作Python解释器
FileSettingsConfigurationProject:untitled3Project interpreteraddSSH interpreterExisting server configuration选择前面配置的host-inaccessible(gpu)movenextfinishOK
四、本地和服务器文件同步
同步到本地:Remote host文件右键点击Download from here
上传到服务器:Project file文件右键点击DeploymentUpload to ...