-
Problem Description
python file.py
It can run normally, anddebug
there will be problems like the question:no such file or directory: '/home/user/.local/lib'
Looking at the running path, it should be
python
aos
path check. -
Thinking combing
debug
Before the actual content of a file, vscode will check first, the function that went wrong is:home/user/anaconda3/lib/python3.8/posixpath.py
in# This will always return false on systems where os.lstat doesn't exist def islink(path): # Test whether a path is a symbolic link try: st = os.lstat(path) except (OSError, ValueError, AttributeError): return False return stat.S_ISLNK(st.st_mode)
OK, here are a few keywords:
[posixpath.py, os.lstat, islink, stat, path, symbolic]
First look at what is inside the two variables of input
path
and outputstat
:path
Ishome/user/.local/lib
this problem of pathstat
Yes<module 'stat' from 'home/user/anaconda3/lib/python3.8/stat.py'>
Then the question is turned into research keywords
(stat.py, posixpath.py)
. These two modules are the problem. It can be seen that the problemstat
isimport stat
in theposixpath.py
middle, so the breakthrough point of the problem is thisposixpath.py
." Understanding in Python posixpath.py " we talked about, and
posixpath.py
that is POSIX system underos.path
the commonmodule
of Source File .islink()
The function is suitable for judging whether the path is a symbolic link , " Understanding what is a symbolic link in Python ".I have sorted out a lot before. The core of the problem is that the os.path module uses a
islink()
function to determinepath=/home/user/.local/lib
whether it is a soft connection error because there is no/home/user/.local/lib
such path.There is indeed no check, how did this path come from. Then find a breakthrough from the principle of vscode debug .
From Python debug configurations in Visual Studio Code , VS Code debug will use the configuration in *.vscode/launch.json , which
path=/home/user/.local/lib
is mostly specified by launch.json*, delete it first, and re-debug
solve the problem. -
solution
Delete the *.vscode/launch.json* file, restart F5 dubug, and solve the problem.
For how to set launch.json,
path=/home/user/.local/lib
please refer to Python debug configurations in Visual Studio Code , which will be explained in detail after it is empty. -
Reference
(20201024Solved)vsCode debug出现no such file or directory:‘/home/user/.local/lib‘
Guess you like
Origin blog.csdn.net/The_Time_Runner/article/details/109277059
Recommended
Ranking