Welcome to my [Zhihu Account] where I do things:Coffee
and my [Station B Marvel Editing Account]:Coffee a> If my notes are helpful to you, please use your little finger to give me a big like. VideosMan
The following is a method that I think is more common. If you are using Python downloaded from the Microsoft store, pay special attention to the following. You’ll understand once you see it
I installed buautifulsoup4 using pip, but vscode just can’t recognize it.
In the picture above, after cmd entered python, importedfrom bs4 import BeautifulSoup
, no error was reported, indicating that there is no problem with buautifulsoup4, but my vscode just cannot recognize it
The idea of vscode is to add your expansion path insetting.json
file. The following is the solution
first step
Your downloadedbeautifulsoup4
file package, first unzip it into your python work project
Step 2
Press and holdctrl+shift+P
, then searchsetting.json
, and then add the following configuration code to your own json configuration file (I added it at the end one line)
"python.analysis.extraPaths": ["输入你的beautifulsoup路径"]
After saving, restart vscode
vscode will be able to recognize this bs4
pay attention
Zhihu is overwhelmingly saying that Python in the Microsoft Store is a nanny-level installation method. In fact, there are things you should pay attention to when downloading from the Microsoft Store.
If you downloaded python from the Microsoft Store, you need to click on the settings at the bottom of vscode
Click on the python version number under vscode, mine is3.10.6
, then vscode will provide different interpreters for python. If you download python from the Microsoft store, it will default to the interpreter with stars. After you switch to the interpreter of Global
, you will find that the problems you encounter are no big deal (the installation package downloaded from the official website is actually not troublesome)
Supplementary knowledge
pip install and uninstall beautifulsoup4
Use pip to install in cmd (choose any method below to install)
C:\Users\admin>pip install beautifulsoup4
C:\Users\admin>pip3 install beautifulsoup4
C:\Users\admin>python -m pip install beautifulsoup4
C:\Users\admin>python3 -m pip install beautifulsoup4
C:\Users\admin>python3 -m pip3 install beautifulsoup4
Check if the installation is successful
pip list
Just have beautiful4 in the list.
Uninstall beautifulsoup4
Similarly, add an install and change it to uninstall.
C:\Users\admin> pip uninstall beautifulsoup4