Python中如何在vscode调试时进入第三方库的代码?

目前,本程序的代码,断点没问题,调试也能进入
但非本程序的就是不行
Python中如何在vscode调试时进入第三方库的代码?

6 回复

老版本的 vscode 里,在 launch.json 的某个配置上加入:
“debugStdLib”: true
新版本的改用:
“justMyCode”: false


在VSCode里想进第三方库源码调试,得先确保你有源码。如果库是纯Python写的,直接装个debugpy,然后在launch.json里加个"justMyCode": false就行。

这是完整的launch.json配置示例:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python Debugger",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "justMyCode": false
        }
    ]
}

设好这个,调试时就能一路Step Into到第三方库的代码里了。不过有些库是C扩展写的,那就进不去了,得看它有没有提供调试版本。

总结:关掉justMyCode就能进第三方库调试。

上面所指的新版本是 2019 四月更新及其之后的 vscode

非常感谢
但这又带来一个问题
外部库每次异常都会暂停
程序启动时 会触发外部库大量的异常——代码不是我写的……
这个怎么解决?

已经解决 去掉 bereakpoints 组件的 raised exceptions 勾选即可
再次感谢

Visual Studio Live Share Linux Dependency Installer

See https://aka.ms/vsls-docs/linux-prerequisites

Visual Studio Live Share requires a number of prerequisites that this script
will attempt to install for you. This process requires admin / root access.

To begin the installation process, your OS will now ask you to enter your
admin / root (sudo) password.

[sudo] password for qgb:

() Detected RHL / Fedora / CentOS

(
) Updating package lists…

() Verifying .NET Core dependencies…
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.cn99.com
* epel: hk.mirrors.thegigabit.com
* extras: mirrors.cn99.com
* updates: mirrors.cn99.com
getpagespeed-extras-noarch | 27 kB 00:00
https://extras.getpagespeed.com/redhat/7/noarch/repodata/repomd.xml: [Errno -1] Error importing repomd.xml for getpagespeed-extras-noarch: Damaged repomd.xml file
Trying other mirror.
Package 1:openssl-libs-1.0.2k-19.el7.x86_64 already installed and latest version
Package krb5-libs-1.15.1-37.el7_7.2.x86_64 already installed and latest version
Package libicu-50.2-3.el7.x86_64 already installed and latest version
Package zlib-1.2.7-18.el7.x86_64 already installed and latest version
Nothing to do
(
) compat-openssl10 not required.

(*) Verifying keyring dependencies…
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.cn99.com
* epel: hk.mirrors.thegigabit.com
* extras: mirrors.cn99.com
* updates: mirrors.cn99.com
getpagespeed-extras-noarch | 26 kB 00:01
https://extras.getpagespeed.com/redhat/7/noarch/repodata/repomd.xml: [Errno -1] Error importing repomd.xml for getpagespeed-extras-noarch: Damaged repomd.xml file
Trying other mirror.
Resolving Dependencies
There are unfinished transactions remaining. You might consider running yum-complete-transaction, or “yum-complete-transaction --cleanup-only” and “yum history redo last”, first to finish them. If those don’t work you’ll have to try removing/installing packages by hand (maybe package-cleanup can help).
–> Running transaction check
—> Package gnome-keyring.x86_64 0:3.28.2-1.el7 will be installed
–> Processing Dependency: /usr/libexec/gcr-ssh-askpass for package: gnome-keyring-3.28.2-1.el7.x86_64
epel/x86_64/filelists_db | 12 MB 00:01
https://extras.getpagespeed.com/redhat/7/noarch/repodata/b7cc25a2fc5f548817b09fda0b5d07df8a72e6581229efb7feb7e708a18443f9-filelists.sqlite.bz2: [Errno 14] HTTPS Error 404 - Not Found
Trying other mirror.
To address this issue please refer to the below wiki article

https://wiki.centos.org/yum-errors

If above article doesn’t help to resolve this issue please use https://bugs.centos.org/.



One of the configured repositories failed (GetPageSpeed packages for Enterprise Linux 7 - noarch),
and yum doesn’t have enough cached data to continue. At this point the only
safe thing yum can do is fail. There are a few ways to work “fix” this:

1. Contact the upstream for the repository and get them to fix the problem.

2. Reconfigure the baseurl/etc. for the repository, to point to a working
upstream. This is most often useful if you are using a newer
distribution release than is supported by the repository (and the
packages for the previous distribution release still work).

3. Run the command with the repository temporarily disabled
yum --disablerepo=getpagespeed-extras-noarch …

4. Disable the repository permanently, so yum won’t use it by default. Yum
will then just ignore the repository until you permanently enable it
again or use --enablerepo for temporary usage:

yum-config-manager --disable getpagespeed-extras-noarch
or
subscription-manager repos --disable=getpagespeed-extras-noarch

5. Configure the failing repository to be skipped, if it is unavailable.
Note that yum will try to contact the repo. when it runs most commands,
so will have to try and fail each time (and thus. yum will be be much
slower). If it is a very temporary problem though, this is often a nice
compromise:

yum-config-manager --save --setopt=getpagespeed-extras-noarch.skip_if_unavailable=true

failure: repodata/b7cc25a2fc5f548817b09fda0b5d07df8a72e6581229efb7feb7e708a18443f9-filelists.sqlite.bz2 from getpagespeed-extras-noarch: [Errno 256] No more mirrors to try.
https://extras.getpagespeed.com/redhat/7/noarch/repodata/b7cc25a2fc5f548817b09fda0b5d07df8a72e6581229efb7feb7e708a18443f9-filelists.sqlite.bz2: [Errno 14] HTTPS Error 404 - Not Found
(!) Keyring installation failed!

Press enter to dismiss this message

回到顶部