This is a summary of what the posters who are new to programming have investigated about the points that were stuck in environmental development. It may contain mistakes. In that case, I would appreciate it if you could let me know.
I created a Python environment with WSL, but when I try to run it with VScode, I get an error "Unable to import ~" and it's annoying!
Windows10 WSL executable
It's because Vscode doesn't tell you exactly where Pytho3 is on WSL.
C:\programming>python
Python 3.8.2 (default, Jul 16 2020, 14:00:26)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/usr/lib/python38.zip', '/usr/lib/python3.8', '/usr/lib/python3.8/lib-dynload', '/home/(User name)/.local/lib/python3.8/site-packages', '/usr/local/lib/python3.8/dist-packages', '/usr/lib/python3/dist-packages']
In this case, the second'/usr/lib/python3.8'is the Path value.
Four. Open ".vscode" in that folder. Open settings.json and copy the previous Path to pythonPath.
{
"python.pythonPath": "/usr/lib/python3.8"
}
Five. Complete
https://qiita.com/dynamonda/items/5a8129cd6e9cc139d94a https://qiita.com/ktgwaaa/items/6d1f54d5ff3c4559f96c
For some reason, it seems that you have to use Remote WSL to fix this called Select Python Interpreter.
Recommended Posts