Home >Backend Development >Python Tutorial >How to add Python interpreter and install Python library in VSCode
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;
check"Add Python 3.7 to PATH" and select "Install Now";
shortcut 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;
Enter interpreter path…" option, select it to enter the next window;
Find" in this window option to open the file explorer;
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!