PyCharm调用wsl调试器问题记录

记录pycharm启动wsl调试器时出现问题和解决方法。

1. 报错:wsl a localhost proxy configuration was detected but not mirrored into wsl

错误原因:wsl 被配置成localhost 代理,网络并没有镜像到wsl内部,配置mirror即可解决

解决方法:%USERPROFILE%下新建 .wslconfig 文件,填入如下内容,然后重启wsl (cmd: wsl –shutdown)

[experimental]
autoMemoryReclaim=gradual  # gradual  | dropcache | disabled
networkingMode=mirrored
dnsTunneling=true
firewall=true
autoProxy=true

参考链接:https://github.com/microsoft/WSL/issues/10753#issuecomment-1814839310

2. 报错: wslproxy closed stream unexpectedly

Help->Find Actions->Registry-> wsl.proxy.connect.localhost: true(check the box)

参考链接: https://youtrack.jetbrains.com/issue/PY-64111/WSL-2.0.9.0networkingModemirroredFastAPIwslproxy-closed-stream-unexpectedly.-See-idea.log-for-errors

3. 调用gui matplotlib imshow

apt install python3-tk

export DISPLAY=localhost:0.0

import matplotlib
matplotlib.use('Agg') # no UI backend

https://stackoverflow.com/questions/43397162/show-matplotlib-plots-and-other-gui-in-ubuntu-wsl1-wsl2

《PyCharm调用wsl调试器问题记录》有1条评论

发表评论