📖 preface

VsCode: Configure your Python development environment! Do not like spray, if you have suggestions welcome to supplement, discussion!

For more information on installation and sinification, see this post from the bloggerDownload and Install VsCodeAs well asPython series: windows10 to configure Python3.0 development environment!Restart VsCode after installation!

🚀 last Come on!

First of all, please make sure that the installation of VsCode and the configuration and installation of Python environment have been completed! If not, please refer to the blogger’s previous post.

  1. First, enter the extension search, enter “python” search, click the python plug-in as shown in the picture to install and restart VsCode.

Check whether Python is installed successfully:

  • Open the command prompt
  • Enter Python and press Enter
  • Enter PIP List to check that the third party package is correct

Install third-party packages:

  • Open the command prompt
  • Enter PIP install Flake8
  • Enter PIP install yapf
  • These two packages are used when configuring VScode’s Python environment

Create a new project

Create a new file, test.py



2. Configure work areas (configure Flake8 and yAPf and close PyLint)





Configure the following code:

{
    "python.linting.flake8Enabled": true,
    "python.formatting.provider": "yapf",
    "python.linting.flake8Args": [
        "--max--line-length=248"
    ],
    "python.linting.pylintEnabled": false
}
Copy the code

3. Configure Python compilation Settings

  • Click Debug on the left and select Add Configuration to bring up Java and Python. Select Python to bring up the launch.json file



  • Add the following configuration (so you don’t have to press F5 twice while compiling), and if you want to debug step by step, change false to true
"stopOnEntry":false,
Copy the code

4. Set environment variables

  • Completing the above configuration does not allow us to debug and run code in VScode
  • Because we haven’t configured the Python path in VScode yet
  • Start launch.json and type “pythonPath” under the debugger used during debugging: the target path
"PythonPath ":" the path where your pytho.exe is located ",Copy the code

5. Configure the default task

  • Complete this step, you can directly through the shortcut keys to get the results of the program
  • Click Terminal, select Configure Default Build Task, and open the task.json file

  • Modify the following configurations
"group":{
    "kind":"build",
    "isDefault":true            
}
Copy the code

6. Perform supplementary configurations

  • File -> Preferences -> Settings -> open setting.json

  • Add configuration to User setting. json:
{"workbench.startupEditor": "newUntitledFile", "python.pythonPath": "your python.exe path ", "python.linting.enabled": false, "editor.fontSize": 14 }Copy the code

7. Save the changes, restart VScode, and open the file for debugging:

"" @name: Sunny Chen @test: test font @msg: this is created by Sunny Chen. List_a =[1,2] list_b=[5,6] ref_list_a=id(list_a) for I in range(1,6): for j in range(1,6): print(str(j)+"\n") print(str(i)+"\n")Copy the code

🎉 finally

  • For more references, see here:Chen Yongjia’s blog
  • Like the little friend of the blogger can add a concern, point a like oh, continue to update hey hey!