How to use pycharm

hint:

pycharm is a professional version; the community version does not currently support debugging Jupyter;
if you are a student, you can apply for a free professional version every year during your studies, and go to Jetbrain to apply for details;

在申请过程中,需要注意, 不要使用代理进行fangqiang, 应在中国的域名下
For the application process, please refer to the Student Application Tutorial here

1 pycharm installation and uninstallation

1.1 Installation

  1. After unzipping, go to binthe folder ./pycharm.sh

  2. After the installation is complete, in tools/ create Desktop Entry

1.2 Uninstall

  1. Uninstall configuration information

In the decompressed pycharm-2020.2.1 folder, check Install-Linux-tar.txt to find the location of the configuration information

~/.config/JetBrains/Pycharm2020.1

Open the terminal under the path of JetBrains, sudo rm -rf Pycharm2020.1

2. Uninstall the installation file
and then return to the decompression file directory in step 1, delete the installation file;
sudo rm -rf pycharm-2020.2.1

1.3 Configure and debug jupyter-notebook.ipynb file in pycharm

debug disconnect
“TypeError: prepare_to_run() got an unexpected keyword argument ‘enable_tracing_from_start’” when debugging a cell

参考 issue : “TypeError: prepare_to_run() got an unexpected keyword argument ‘enable_tracing_from_start’” when debugging a cell

Professional version 2020.1
downgrades ipykernel to below 5.5.4;

conda install ipykernel== 5.5.4
or pip install ipykernel == 5.5.4

In the latest version 2021.3.2;
can use ipykernl == 6.4.1;


2. Debugging

  1. During the debugging process, in addition to the normal use of the breakpoint debugging method; when debugging to the last line of the cell, run to cursor (F9) jumps to the next breakpoint, thereby jumping out of the current cell debugging;
  2. When you want to see how some functions or classes are implemented, you can select the class or function and use go to decarlation or usages;
  3. Among them, when a function B calls the previous function function A; then before debugging B, the function function A must be debugged first;

2.1 The difference between red and blue during debugging

Personally, in the pycharm 2021.3.2 version:
the appearance of red and blue should be to show that each step, the variables are
suggested to MainThreadunderstand ;

2.1.1. When there is no loop in the current Main Thread

Red: Under normal circumstances, it represents the variables generated in the previous Thread;
2. Blue: The variables generated in the current Thread;
that is, the variables in the current Thread should be all blue;

2.1.2. When the current Main Thread loops

However, under normal circumstances, there will be a loop structure in the current Thread code:
Red: the variable in the current Thread, and the variable in the loop body, when the variable changes, it will change from blue to red, and only appear in the loop body When the variable changes, it also turns from blue to red;
blue: the variable in the current Thread, but outside the loop, when the variable changes, it still remains blue;

2.1.3. After the loop,

The variables generated by the current Main Thread are displayed in blue, no matter whether they appear in the loop body or not;

3. Code comments in Pycharm

Alt + enter: code regularization, and redundant parameter deletion;
two consecutive shifts: find the selected character;

3.1 Parameter Description of Function Parameters

When constructing a function, the parameter variable in the function 
can select a variable in the code comment,
so that in the function, all relevant places related to the variable are displayed;

Note that when writing the formal parameters of the function,

非默认形参,需要放在默认形参(即以及赋初值的)前面

In pycharm, this function is integrated;
specifically in Settings -> Tools -> python integration tools -> Docstring format;

Select the format in the docstring;

Google style can be selected;

insert image description here

3.2 Select the highlight of the same variable in the code

Highlight the same variable name in the code

install a plugin

setting  >>>  plugins
在搜索栏输入BrowseWordAtCaret

insert image description here

enable:

insert image description here

3.3 Highlighting keywords in custom comments

Settings –> Editor – “TOdo
insert image description here

Guess you like

Origin blog.csdn.net/chumingqian/article/details/129408228