'ModuleNotFoundError: No module named 'bs4' just in Visual Studio Code
I have a .py script which I have open in Virtual Studio Code. One of my libraries (bs4) is not getting imported successfully, it says:
ModuleNotFoundError: No module named 'bs4'
I've tried to pip install bs4 in my command line, but the library was already there.
However, I've run the exact same script in Jupyter Notebooks (installed by anaconda package) and the library existed and the script worked as expected.
How can I get VS Code to use the same libraries as Jupyter Notebooks is using?
Solution 1:[1]
Try changing the python 3 interpreter:
- Click the interpreter button in the bottom left (bottom blue ribbon): https://i.stack.imgur.com/4H2AL.png
- Try running with the different Python 3 interpreter paths until you find one which works - https://i.stack.imgur.com/wY1Ld.png
Solution 2:[2]
Your system almost certainly has more than one Python installation. Running pip from the command line is working with a different version to the one that Visual Studio Code is configured to use
Solution 3:[3]
Please use this command for installing bs4
on Visual Studio Code on the terminal:
py -m pip install bs4
Don't use this:
pip install bs4
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | function-hack |
Solution 2 | |
Solution 3 | Gino Mempin |