zoukankan      html  css  js  c++  java
  • PyCharm Notes | PyCharm 使用笔记(远程访问服务器code配置指南)

    PyCharm is a strong IDE for python programmer. Not only because it has a similar face with VS or some other IDEs, but also it provides a convenient way to remote manage codes. 

    But... how to configure it to achieve this is a headache problem. Here I saved a good guidebook.

     

    0. A professional version must be needed.

    Community version PyCharm has no remote management function. Luckily, I am a student yet so I can use my edu.cn email address to use the professional version for free.

     

    1. Some explicit concepts should be understood.

    Here are two concepts may help you have an overall view, Interpreter and Deployment. 

    An interpreter is used to run python code. Obviously, you should use your server interpreter to do this instead of running on your local computer. So the first thing you have to do is setting interpreter of PyCharm.

    And what makes PyCharm so charming is exactly Deployment. Actually, it is a GitHub-like thing. With it, you can pull code from the server and push edited version back. What you need to do is tell Deployment where are your local codes and remote codes. Yes, just two paths.

     

    2. Now we can do it.

    (1) Create a new project with PyCharm. Your local codes will be saved in this project.

    (2) Interpreter Configuration: Open the new project in PyCharm. Click File -> Settings -> Project: xxx -> Project Interpreter. Now you can find the project interpreter. Click the gear-shaped button, choose to add. Here we should add an SSH interpreter. Input your Host address and username. The things behind are too simple to descript here. 

    (If you use Anaconda rather than system interpreter, you can refer to 3(1) below.)

    (3) Deployment Configuration: Click Tools -> Deployment -> Configuration. Now you can configure Deployment. Here are three tabs named Connection, Mappings and Excluded Paths. The connection is some information to link your server. And mapping is a corresponding relationship between a local project path with the server project path. Just two root directories' paths. 

     

    3. More tricks.

    (0) A virtual environment is better. You can use Anaconda to create a virtual environment on the server, then link it in the PyCharm Interpreter. The system interpreter path is /usr/bin/python, but the Anaconda interpreter path is anaconda3/envs/{ENV_NAME}/bin/python.

    (1) In the terminal tab of PyCharm, you can use SSH command to log in your server.

    (2) Maybe you cannot run via clicking the green triangle button. You should use Run in the menu bar. 

    (3) If some problems happened when you are running codes, it may because your server interpreter environment is wrong configuring. Make sure you can run codes correctly on your server before running it in the PyCharm.

    (4) If you wanna run codes on server, just put parameters into Run Configurations/Configuration/Parameters and put "CUDA_VISIBLE_DIVICES=..." into Run Configurations/Configuration/Environment variables.

     

    Reference:

    http://www.xzhewei.com/Tutorial-%E6%95%99%E7%A8%8B/remote-debug/

    https://www.xncoding.com/2016/05/26/python/pycharm-remote.html

  • 相关阅读:
    10、ERP设计之系统基础管理(BS)- 平台化设计
    SendMessage发送自定义消息及消息响应
    【iOS开发】 常遇到的Crash和Bug处理
    UVA 11100 The Trip, 2007 贪心(输出比较奇葩)
    Android_多媒体_SoundPool声音池使用
    Django之逆向解析url
    Oracle中四种循环(GOTO、For、While、Loop)
    Android监控程序本身被卸载方法汇总
    Cocos2dx项目启程一 之 封装属于我的精灵类
    Android-->发送短信页面实现(短信发送以及群发和从电话本中选择联系人)-----------》2
  • 原文地址:https://www.cnblogs.com/hizhaolei/p/10001459.html
Copyright © 2011-2022 走看看