8
votes

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

2
any solution yet? - PATAPOsha
@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. - m0r7y
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. - m0r7y
replacing wls 2 "public" adress with localhost leads to ConnectionRefusedError: [Errno 111] Connection refused for me. tried from cmd - PATAPOsha
@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). - m0r7y

2 Answers

9
votes

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

0
votes

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