Let's talk about how to configure the python environment in vscode
How to configure the python environment in vscode? The following article will introduce to you how to configure the python environment in Visual Studio Code. I hope it will be helpful to you!
Preliminary configuration
Install python (It is recommended to install it directly in the system directory and check Select 'ADD TO PATH' to avoid unnecessary trouble)
Install Visual Studio Code (the official website speed is sometimes fast and sometimes slow, it is recommended to download by chance, or use a reliable ladder to download ). [Recommended study: "vscode introductory tutorial"]
-
Check whether python and VSC are installed
- python: In cmd or Enter python --version in the terminal. If the version number can be output, the installation is successful (the latest version: 3.9.1)
- pip: python's current mainstream package management tool. In the latest version, pip will be along with python. Install together and complete the system variable settings. Enter pip -V[–version] in cmd or terminal. If the version number can be correctly output, the installation is successful
1. Establish a virtual environment (venv)
The role of venv can be understood as a python environment established for a specific project, which can be understood as a child. When we develop this project, we only need to operate the venv. Problems with the venv will not have an impact on the overall situation. To create venv, you need:
1. Create a folder in the appropriate path (you may wish to set it to venv-demo)
2. Run terminal or cmd in the folder, Enter the following command
python -m venv env
Then a folder named env will be generated under the folder, which is the virtual environment generated for us .
3. Enter the following command in terminal or cmd
Set-ExecutionPolicy -Scope CurrentUser remotesigned
Set the current user to be able to run wps scripts .
You can also run wps as an administrator and remove the -Scope attribute to set all users to be able to run wps scripts (those previously set can ignore step 3)
4. Enter env folder, execute the following command
.\Scripts\activate
to open the virtual environment. Enter exit
to exit.
2. Configure pip
Due to well-known reasons, the installation speed of pip without modifying the source of pip in mainland China will be very impressive. So we need to configure pip in the virtual environment.
1. Under the premise of opening the virtual environment, enter pip config debug
to check whether there is a corresponding pip configuration file. We only need to create the pip configuration file in the virtual environment.
2. Create the pip.ini file in the env folder
3. Open the pip.ini file and make the following settings:
[global] index-url = https://mirrors.aliyun.com/pypi/simple/ [install] trusted-host = mirrors.aliyun.com
Many commercial companies and universities in China have established pip As for the mirror site, I personally think Alibaba is the best here. Set the index-url and trusted-host respectively, and run pip install [module_name]
and the download speed will be acceptable.
3. Set up VSC
Open the venv-demo folder with VSC
At this time VSC may remind you to install the pylint package, just install it
Click
ctrl shift p
to open the settings panel and searchPython:Select Interpreter
option, select python.exe of the virtual environment env as the interpreterAt this time click
ctrl~
Open the terminal, you can see that you have automatically entered the virtual environment of envCreate the demo.py file in venv-demo, write anything, and then enter
python demo.py
in the terminal. It can run normally and the configuration is successful.
For more knowledge about VSCode, please visit: vscode tutorial! !
The above is the detailed content of Let's talk about how to configure the python environment in vscode. For more information, please follow other related articles on the PHP Chinese website!

VisualStudio and VSCode have their own advantages and disadvantages, which are suitable for different development needs. VisualStudio is suitable for large projects and provides rich functions; VSCode is lightweight, flexible, and has cross-platform support.

VisualStudio is a multi-functional integrated development environment that supports multiple programming languages and complete development processes. 1) Code editing: Provides intelligent code completion and reconstruction. 2) Debugging: Built-in powerful debugging tools, supporting breakpoint and variable monitoring. 3) Version control: Integrate Git and TFVC to facilitate team collaboration. 4) Testing: Supports multiple test types to ensure code quality. 5) Deployment: Provides a variety of deployment options to support deployment requirements from on-premises to the cloud.

VisualStudio is suitable for large-scale project development, while VSCode is suitable for lightweight and highly customizable environments. 1. VisualStudio provides powerful intelligent perception and debugging functions, suitable for large-scale projects and enterprise-level development. 2. VSCode provides flexibility and customization capabilities through extended systems, suitable for multiple programming languages and cross-platform development.

VisualStudio subscriptions are available in multiple levels, suitable for different developers' needs. 1. The basic version is free and suitable for individuals and small teams. 2. Advanced versions such as Professional and Enterprise provide advanced tools and team collaboration functions, suitable for enterprise users.

The difference between VisualStudio and VSCode in performance and resource usage is mainly reflected in: 1. Startup speed: VSCode is faster; 2. Memory usage: VSCode is lower; 3. CPU usage: VisualStudio is higher during compilation and debugging. When choosing, it must be determined based on project requirements and development environment.

VisualStudio (VS) is a powerful integrated development environment (IDE) developed by Microsoft, which supports multiple programming languages, such as C#, C, Python, etc. 1) It provides a rich set of features including code editing, debugging, versioning and testing. 2) VS processes code through powerful editors and debuggers, and supports advanced code analysis and reconstruction using Roslyn and Clang/MSVC compiler platforms. 3) Basic usage is like creating a C# console application, and advanced usage is like implementing polymorphism. 4) Common errors can be debugged by setting breakpoints, viewing output windows, and using instant windows. 5) Performance optimization suggestions include the use of asynchronous programming, code reconstruction and performance analysis.

In VisualStudio, the steps for compiling, testing and deploying the code are as follows: 1. Compiling: Use VisualStudio's compiler options to convert source code into executable files, supporting multiple languages such as C#, C and Python. 2. Testing: Use built-in MSTest and NUnit to perform unit testing to improve code quality and reliability. 3. Deployment: Transfer applications from the development environment to the production environment through web deployment, Azure deployment, etc. to ensure security and performance.

VisualStudioisMicrosoft'sflagshipIDE,supportingmultipleprogramminglanguagesandenhancingcodingefficiency.1)ItoffersfeatureslikeIntelliSenseforcodeprediction,multi-tabbedinterfaceforprojectmanagement,andtoolsfordebugging,refactoring,andversioncontrol.2


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SublimeText3 Chinese version
Chinese version, very easy to use

Dreamweaver CS6
Visual web development tools

Notepad++7.3.1
Easy-to-use and free code editor

WebStorm Mac version
Useful JavaScript development tools
