Double-click the "VSCodeUserSetup-x64-1.74.2.exe" installation package; select "I agree to this agreement" and click Next;
Select the default path and click Next;
Select Next;
Check "Create desktop shortcut" "Method" and click Next;
Click to install;
##After the installation is complete, click Finish; VScode is installed successfully. ; two. Install the Python interpreterDouble-click "python-3.7.2-amd64(1).exe" andcheck"Add Python 3.7 to PATH" and select "Install Now";
Wait for the installation progress bar to finish loading; Click Close after the installation is successful; at this point Python The interpreter was installed successfully; #3. Add the Python interpreter to VScodea) Double-click the installed VScode icon on the desktop to enter the VScode software interface; b) Install the Python plug-in: First click "Extensions" and enter Python in the search box, then select Install in the lower right corner of the Python plug-in; c) Add a Python interpreter: Pressshortcut Press "Ctrl Shift P" to bring up the global settings search window, then enter "Python:Select Interpreter" and the "Python:Select Interpreter" option will appear. Click this option;
d) Clicking this option will jump to the Python interpreter configuration window, which displays the added Python interpreter; if you want to add a new Python interpreter, you need to click "Enter interpreter path…" option, select it to enter the next window;
e) Click "Find" in this window option to open the file explorer;
f) and then find the Python3.7.2 interpreter installation directory that needs to be added (that is, the default path for installing the Python interpreter in the second step), And select "Python.exe" and then click the "Select Interpreter" button. At this time, the Python3.7.2 interpreter has been added to the VScode editor;Note: If the "AppDate" folder cannot be found in the Python installation path, you need to perform this operation: click "View" —> "Show" —> "Hidden Projects" , you can find the "AppDate" folder
ii. In VScode, click "File" and select "Open Folder" to add the newly created "AI-case" on the desktop;
iii. Click OK after adding "AI-case" and select "Yes, I trust the authors";
iv. Add it in In the "AI-case" project, click "New fiel..." to create a new text.py;
v. In the created text.py, enter "print(‘ hello world’)" and click the run button to get the running results in the terminal;
Make sure The Python3.7.2 interpreter has been added to VScode: you can see the content as shown below in the lower right corner of VScode, which indicates that Python3.7.2 is correctly selected;
in the edit bar Enter "import requests" and click the run button, the following error will appear: " ModuleNotFoundError: No module named "requests", so the requests library needs to be installed;
Click the run button to run the text.py file to get the installation path of Python3.7.2 in Terminal;
Enter the Scripts folder in the Python3.7.2 installation directory in Terminal: enter cd and space the installation path of Python3.7.2\Scripts\; hit Enter; be careful not to copy python when copying the installation path of Python3.7.2. exe
After confirmation, if the path to the folder Scripts appears directly in Terminal, enter: ".\pip install requires the installation library name", ( For example: .\pip install requests), press Enter and wait for the installation to be successful;
The above is the detailed content of How to add Python interpreter and install Python library in VSCode. For more information, please follow other related articles on the PHP Chinese website!