How to be in vscode Install in python library
1. Already in vscode It's in Chinese python And configured python Running environment .
Check whether the running environment is configured correctly , Press Windows+R Key combination: enter... In the operation window cmd, Open a command prompt window and enter python Sure you can.
2. find vscode in python The path of
Run any code , for example print(“hehe”) The following terminal displays
Circled in red in the picture is python The path of , To python3.8 until .
If what you show is different from me , Can be found in setting.json Find and copy the path in ( stay vscode I've configured python The environment should be found )
3. The official start of the
stay vscode Open the terminal , Click on View, Click... In the selection bar that appears Terminal( Integrated terminal ) You can open
After opening the terminal , We enter... In the terminal python Install under directory Scripts Folder : Input cd+ Format + The path just copied +\Scripts\
After confirmation, if the folder appears directly on the terminal Scripts The path of , Input ".\pip install Need to install library name " Make sure to wait for the installation to succeed ( If it fails, you can install it several more times , Maybe it will work ).
I installed numpy For example :
Of course, if you are typing “cd+ Format + The path just copied +\Scripts\” after , Did not jump out Scripts The path of , But just like me vscode The path of ( As shown in the figure below )
Click the link to open the address directly , You can choose to create a new window , You can also not create a new , At this time, the terminal will have Scripts The path of , Enter after .\pip install numpy that will do .