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

  • 相关阅读:
    c# webapi 在swagger里添加全局过滤器
    axios get,post请求时带headers
    svn"重新定位"提示版本库uuid不匹配
    DevExpress XtraReport
    DevExpress GridControl List绑定方式下新增行的方法
    对Dev的GridControl/GridView控件进行分组并展开操作
    DevExpress GridControl控件行内新增、编辑、删除添加选择框
    JavaScript 中的FileReader对象(实现上传图片预览)
    数据库连接情况查询
    C#代码中实现两个表(DataTable)的关联查询(JOIN)
  • 原文地址:https://www.cnblogs.com/hizhaolei/p/10001459.html
Copyright © 2011-2022 走看看