9

I set up Pycharm to use a virtualenv inside wls 2,
It works fine, I mean, I can run my project throught the button "run",
The problem is I can't use the debugger, it's says connection time out, let me show you the full [erros][1].
('Connecting to ', '172.21.176.1', ':', '63597')
Could not connect to 172.21.176.1: 63597

It seems that when I run with debug mode, It wants to connect to 172.21.176.1 (wsl 2 ip adress),
but it should connect to 127.0.0.1 because the process is launched by ubuntu2004.exe.
Can you help me?
Error:

C:\Users\tux\AppData\Local\Microsoft\WindowsApps\ubuntu2004.exe run "export IDE_PROJECT_ROOTS=/mnt/c/Users/tux/Documents/projects/odoo/13 && export PYCHARM_DEBUG=True && export PYTHONUNBUFFERED=1 && export IPYTHONENABLE=True && export PYCHARM_HOSTED=1 && export PYTHONIOENCODING=UTF-8 && export PYCHARM_DISPLAY_PORT=63342 && export PYTHONDONTWRITEBYTECODE=1 && export PYDEVD_LOAD_VALUES_ASYNC=True && export "LIBRARY_ROOTS=/mnt/c/Users/tux/AppData/Local/JetBrains/PyCharm2020.1/remote_sources/525578736/201545293:/mnt/c/Users/tux/AppData/Local/JetBrains/PyCharm2020.1/remote_sources/525578736/1688665391:/mnt/c/Users/tux/AppData/Local/JetBrains/PyCharm2020.1/python_stubs/525578736:/mnt/d/Program Files/JetBrains/PyCharm 2020年1月2日/plugins/python/helpers/python-skeletons:/mnt/d/Program Files/JetBrains/PyCharm 2020年1月2日/plugins/python/helpers/typeshed/stdlib/3.7:/mnt/d/Program Files/JetBrains/PyCharm 2020年1月2日/plugins/python/helpers/typeshed/stdlib/3:/mnt/d/Program Files/JetBrains/PyCharm 2020年1月2日/plugins/python/helpers/typeshed/stdlib/2and3:/mnt/d/Program Files/JetBrains/PyCharm 2020年1月2日/plugins/python/helpers/typeshed/third_party/3:/mnt/d/Program Files/JetBrains/PyCharm 2020年1月2日/plugins/python/helpers/typeshed/third_party/2and3" && export "PYTHONPATH=/mnt/c/Users/tux/Documents/projects/odoo/13:/mnt/d/Program Files/JetBrains/PyCharm 2020年1月2日/plugins/python/helpers/pycharm_matplotlib_backend:/mnt/d/Program Files/JetBrains/PyCharm 2020年1月2日/plugins/python/helpers/pycharm_display:/mnt/d/Program Files/JetBrains/PyCharm 2020年1月2日/plugins/python/helpers/third_party/thriftpy:/mnt/d/Program Files/JetBrains/PyCharm 2020年1月2日/plugins/python/helpers/pydev:/mnt/c/Users/tux/AppData/Local/JetBrains/PyCharm2020.1/cythonExtensions:/mnt/c/Users/tux/Documents/projects/odoo/13" && cd /mnt/c/Users/tux/Documents/projects/odoo/13 && /opt/interpreters/python3.8_odoo_13/bin/python3 "/mnt/d/Program Files/JetBrains/PyCharm 2020年1月2日/plugins/python/helpers/pydev/pydevd.py" --multiproc --qt-support=auto --client 172.21.176.1 --port 63597 --file /mnt/c/Users/tux/Documents/projects/odoo/13/odoo-bin -c conf/learning.conf" Executing PyCharm's sitecustomize Traceback (most recent call last): File "/mnt/d/Program Files/JetBrains/PyCharm 2020年1月2日/plugins/python/helpers/pycharm_matplotlib_backend/sitecustomize.py", line 43, in import matplotlib ModuleNotFoundError: No module named 'matplotlib' Unable to load jupyter_debug plugin Executing file /mnt/c/Users/tux/Documents/projects/odoo/13/odoo-bin arguments: ['/mnt/c/Users/tux/Documents/projects/odoo/13/odoo-bin', '-c', 'conf/learning.conf'] PYDEVD_FILTER_LIBRARIES False

Started in multiproc mode

('Connecting to ', '172.21.176.1', ':', '63597') Could not connect to 172.21.176.1: 63597 Traceback (most recent call last): File "/mnt/d/Program Files/JetBrains/PyCharm 2020年1月2日/plugins/python/helpers/pydev/_pydevd_bundle/pydevd_comm.py", line 456, in start_client s.connect((host, port)) socket.timeout: timed out Traceback (most recent call last): File "/mnt/d/Program Files/JetBrains/PyCharm 2020年1月2日/plugins/python/helpers/pydev/pydevd.py", line 2131, in main() File "/mnt/d/Program Files/JetBrains/PyCharm 2020年1月2日/plugins/python/helpers/pydev/pydevd.py", line 2013, in main dispatcher.connect(host, port) File "/mnt/d/Program Files/JetBrains/PyCharm 2020年1月2日/plugins/python/helpers/pydev/pydevd.py", line 1788, in connect self.client = start_client(self.host, self.port) File "/mnt/d/Program Files/JetBrains/PyCharm 2020年1月2日/plugins/python/helpers/pydev/_pydevd_bundle/pydevd_comm.py", line 456, in start_client s.connect((host, port)) socket.timeout: timed out

Process finished with exit code 1

AzyCrw4282
7,9145 gold badges26 silver badges43 bronze badges
asked Jul 4, 2020 at 15:49
6
  • any solution yet? Commented Jul 6, 2020 at 8:40
  • @PATAPOsha, not yet but I have some hypothesis. If i can set the --listen paramter to localhost, I think it will works. The problem is that it wants to connect to 172.21.176.1 (wls 2 "public" adress). Busy right now, and will dig it after. Commented Jul 6, 2020 at 8:52
  • Because when I connect to the postgresql (inside the wsl) instance, I use localhost not 172.21.176.1 when I configured my Pycharm to use WSL. Commented Jul 6, 2020 at 8:55
  • replacing wls 2 "public" adress with localhost leads to ConnectionRefusedError: [Errno 111] Connection refused for me. tried from cmd Commented Jul 6, 2020 at 9:04
  • @PATAPOsha, You don't have to replace the wls 2 "public" adress. What you have to do is replacing the debugeur parameter --client 172.21.176.1 (sorry, it's client not listen) to 127.0.0.1. (You can see all python debugeur parameter in traceback above). Commented Jul 6, 2020 at 9:16

2 Answers 2

13

Firewall was the case. Unbloking connections from Pycharm (Eset firewall in my case) helped. See https://youtrack.jetbrains.com/issue/PY-39051

answered Jul 6, 2020 at 11:51
Sign up to request clarification or add additional context in comments.

3 Comments

Let me try that,
Saved my day, WSL is treated as a public network, and the correpsonding firewall rule was the issue!
The following worked for me. "Open windows firewall settings, and remove the vEthernet (WSL) connection for each of the Domain, Private, and Public profiles" github.com/microsoft/WSL/issues/4139
0

It's hard to tell where this could be going wrong but you can try to reconfigure your interpreter to use host and port of your choice; the GUI instance is shown in the image.

enter image description here

You can also see this raised issue here - Python debugger not working while normal run does

answered Jul 5, 2020 at 11:19

5 Comments

let me try this one and will give yout feedback
that is deployment settings, not conncted to virtualenv inside wsl2
Hmm. I have never worked on such an environment before so I am indeed lost on how this could be solved. As you mentioned above If i can set the --listen paramter to localhost, I think it will works. This would surely solve the problem and to set that configuration you would need to do it in the interpreter configuration settings. Right?
--listen paramter to localhost didnt work. Unfortunately there is no any debugger configurations for wsl interpreter
@AzyCrw4282, not from interpreter settings, not from "run/debug" configuration

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.