I know this is a many times questions but I still couldn't find the easiest way to resolve my question:
Recently I have got a import error for 'lxml' and I found that this error only occur when I use Visual Studio Code (VSC) but the script can execute perfectly fine when using 'python3' command in terminal
After I read several post from the forum, seems my questions is I should change my VSC parameter by using Python 3.9 instead of 3.8.
Demonstration in Terminal - Python3 works
Demonstration in VSC using 'Run Without Debugging'
Error: ImportError: cannot import name 'etree' from 'lxml' (/Users/LSH/Library/Python/3.8/lib/python/site-packages/lxml/init.py)
When I check with my VSC, I could see that in the left bottom is using Python3.8.2 64 Bit. So I am wonder once I change it to Python 3.9, then my current issue would be resolved?
Or should I update the python file?
As I open the /usr/bin/python3, it is Python 3.8.2
Hope I could get the right answer soon :) Thanks all.
@Update: After below suggestion, I tried to "Select Interpreter" by clicking Command + Shift + P, however, it shows the below options which I couldnt see Python 3.9, do you know where is the exact Python3.9 interpreter? (As all options point to /usr/bin/python3 which should be 3.8.2)
Do it like this- First click on Python 3.8.2 (your 4th picture). Then you will get an option to configure your python interpreter. Select the required version.