Import error resolution record when touching Python code from VSCode

Overview It all started when I tried to use BeautyfilSoupr for web scraping.

Install BeautifilSoup using conda in Anaconda installation environment

conda install beautifilsoup4

After that, I entered import in VSCode as follows, but an error occurred.

image.png ʻUnable to import. Is conda install` not working?

Cause This article was very helpful. https://qiita.com/myasu398/items/5b0f321491a1bed77aa3

The mac default Python interpreter seems to be deprecated in VS Code, and it can be resolved by setting it.

Solution Select Python: Select Interpreter from command. image.png

Then, the available Python execution environment is displayed as follows. In my case, the following display. image.png There were two versions of Python in Anaconda or Not Anaconda. .. ..

Apparently, in my case, the execution environment was an environment other than Anaconda. By choosing Anaconda, the problem was solved.

Postscript

When I selected the Anaconda environment, the import of another Python file I created earlier failed. .. .. Probably because the library imported in the previous environment is not in the Anaconda environment. It's ridiculous to spend time on these silly things, so it seems better to put them in either environment. When you have time, let's move to the Anaconda environment.

Recommended Posts

Import error resolution record when touching Python code from VSCode
Python from or import
[Note] Anaconda & VScode has trouble with python import error
Stop Omxplayer from Python code
Error when playing with python
Error resolution python version check
Error notification method when calling python from windows GUI or winsound.Beep
[python] Error when installing library ramkan
python> link> from __future__ import absolute_import
About Python, from and import, as
Resolve VS Code unresolved import error
Execute Python code from C # GUI
Python error detection run from Powershell
Precautions when using phantomjs from python
[VS Code] ~ Tips when using python ~
How to deal with OAuth2 error when using Google APIs from Python
Precautions and error handling when calling .NET DLL from python using pythonnet
Avoid run-time error ModuleNotFoundError for executables generated from Python code using Pyinstaller
Error resolution when installing numba on macOS
Import error even though python is installed
windows7 / python3.3 / virtualenv / cx_Freeze / Import Error / MAXREPEAT
[Note] Execute Python code from Excel (xlwings)
When Python "Syntax Error: Non-ASCII character ~" appears
Import Error in Python3: No module named'xxxxx'