Python debugger not working while normal run does
已回答
The python debugger in Pycharm (I've the latest version) is not working for any Python file (so it's not my project or anything). While running the file normally in Pycharm works perfectly.
Also the window saying "Python has stopped working" keeps popping up even though I'm not running anything.
I updated my Java version following some advice on a post but it doesn't help.
Here's the log from idea.log file:
2018-08-07 11:40:41,348 [ 257607] ERROR - python.debugger.PyDebugProcess - socket closed
java.net.SocketException: socket closed
at java.net.TwoStacksPlainSocketImpl.socketAccept(Native Method)
at java.net.AbstractPlainSocketImpl.accept(AbstractPlainSocketImpl.java:409)
at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:199)
at java.net.ServerSocket.implAccept(ServerSocket.java:545)
at java.net.ServerSocket.accept(ServerSocket.java:513)
at com.jetbrains.python.debugger.pydev.transport.ServerModeDebuggerTransport.waitForConnect(ServerModeDebuggerTransport.java:39)
at com.jetbrains.python.debugger.pydev.RemoteDebugger.waitForConnect(RemoteDebugger.java:89)
at com.jetbrains.python.debugger.pydev.MultiProcessDebugger.waitForConnect(MultiProcessDebugger.java:80)
at com.jetbrains.python.debugger.PyDebugProcess$5.run(PyDebugProcess.java:295)
at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:736)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$1(CoreProgressManager.java:157)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:580)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:525)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:85)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:144)
at com.intellij.openapi.progress.impl.CoreProgressManager$4.run(CoreProgressManager.java:395)
at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:310)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
2018-08-07 11:40:41,349 [ 257608] ERROR - python.debugger.PyDebugProcess - PyCharm 2018.2 Build #PC-182.3684.100
2018-08-07 11:40:41,349 [ 257608] ERROR - python.debugger.PyDebugProcess - JDK: 1.8.0_152-release
2018-08-07 11:40:41,349 [ 257608] ERROR - python.debugger.PyDebugProcess - VM: OpenJDK 64-Bit Server VM
2018-08-07 11:40:41,349 [ 257608] ERROR - python.debugger.PyDebugProcess - Vendor: JetBrains s.r.o
2018-08-07 11:40:41,349 [ 257608] ERROR - python.debugger.PyDebugProcess - OS: Windows 10
2018-08-07 11:40:41,349 [ 257608] ERROR - python.debugger.PyDebugProcess - Last Action: Debug
2018-08-07 11:40:46,115 [ 262374] INFO - .skeletons.PySkeletonRefresher - Skeleton for PyQt5.QtBluetooth
2018-08-07 11:40:48,807 [ 265066] INFO - .skeletons.PySkeletonRefresher - Skeleton for PyQt5.QtCore
2018-08-07 11:40:50,179 [ 266438] INFO - .skeletons.PySkeletonRefresher - Skeleton for PyQt5.QtDBus
请先登录再写评论。
Same problem here. No debug either with Python 2.7 or Python 3.6.
I also created a new project with only one file and it didn't work. Normal run (CTRL+SHIFT+F10) works ok.
PyCharm 2018.2.3 (Community Edition)
Build #PC-182.4323.49, built on September 4, 2018
JRE: 1.8.0_152-release-1248-b8 x86
JVM: OpenJDK Server VM by JetBrains s.r.o
Windows 7 6.1
Anaconda 3.6 32bits + Anaconda 2.7 32bits
------ LOG MESSAGE ------
2018-09-21 10:13:51,872 [ 940906] ERROR - python.debugger.PyDebugProcess - socket closed
java.net.SocketException: socket closed
at java.net.TwoStacksPlainSocketImpl.socketAccept(Native Method)
at java.net.AbstractPlainSocketImpl.accept(AbstractPlainSocketImpl.java:409)
at java.net.PlainSocketImpl.accept(PlainSocketImpl.java:199)
at java.net.ServerSocket.implAccept(ServerSocket.java:545)
at java.net.ServerSocket.accept(ServerSocket.java:513)
at com.jetbrains.python.debugger.pydev.transport.ServerModeDebuggerTransport.waitForConnect(ServerModeDebuggerTransport.java:39)
at com.jetbrains.python.debugger.pydev.RemoteDebugger.waitForConnect(RemoteDebugger.java:89)
at com.jetbrains.python.debugger.pydev.MultiProcessDebugger.waitForConnect(MultiProcessDebugger.java:80)
at com.jetbrains.python.debugger.PyDebugProcess$5.run(PyDebugProcess.java:295)
at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:736)
at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$1(CoreProgressManager.java:157)
at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:580)
at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:525)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:85)
at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:144)
at com.intellij.openapi.progress.impl.CoreProgressManager$4.run(CoreProgressManager.java:395)
at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:314)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
2018-09-21 10:13:51,875 [ 940909] ERROR - python.debugger.PyDebugProcess - PyCharm 2018.2.3 Build #PC-182.4323.49
2018-09-21 10:13:51,876 [ 940910] ERROR - python.debugger.PyDebugProcess - JDK: 1.8.0_152-release
2018-09-21 10:13:51,877 [ 940911] ERROR - python.debugger.PyDebugProcess - VM: OpenJDK Server VM
2018-09-21 10:13:51,877 [ 940911] ERROR - python.debugger.PyDebugProcess - Vendor: JetBrains s.r.o
2018-09-21 10:13:51,877 [ 940911] ERROR - python.debugger.PyDebugProcess - OS: Windows 7
2018-09-21 10:13:51,878 [ 940912] ERROR - python.debugger.PyDebugProcess - Last Action: ChooseDebugConfiguration
I have a fresh installation of the Pycharm PyCharm 2018.2.3 and Python 3.7.0. I can run a simple program without any problem:
print("message")
But when I try to debug it, I get and error message (see below). There is no problem with the debug and run if I use Python 2.7.5.
Copy/paste of the error:
C:\Users\Name\AppData\Local\Programs\Python\Python37-32\python.exe "C:\Program Files\JetBrains\PyCharm Community Edition 2018.2.3\helpers\pydev\pydevd.py" --multiproc --qt-support=auto --client 127.0.0.1 --port 52311 --file C:/Users/Name/PycharmProjects/2nd/Test.py
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.2.3\helpers\pydev\_pydevd_bundle\pydevd_cython_wrapper.py", line 2, in <module>
from _pydevd_bundle_ext.pydevd_cython import trace_dispatch, PyDBAdditionalThreadInfo, global_cache_skips, global_cache_frame_skips
ModuleNotFoundError: No module named '_pydevd_bundle_ext'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.2.3\helpers\pydev\pydevd.py", line 28, in <module>
from _pydevd_bundle.pydevd_additional_thread_info import PyDBAdditionalThreadInfo
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.2.3\helpers\pydev\_pydevd_bundle\pydevd_additional_thread_info.py", line 17, in <module>
from _pydevd_bundle.pydevd_cython_wrapper import PyDBAdditionalThreadInfo
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.2.3\helpers\pydev\_pydevd_bundle\pydevd_cython_wrapper.py", line 32, in <module>
mod = __import__(check_name)
File "_pydevd_bundle\pydevd_cython_win32_37_32.pyx", line 139, in init _pydevd_bundle.pydevd_cython_win32_37_32
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.2.3\helpers\pydev\_pydevd_bundle\pydevd_breakpoints.py", line 16, in <module>
from _pydevd_bundle.pydevd_comm import get_global_debugger
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.2.3\helpers\pydev\_pydevd_bundle\pydevd_comm.py", line 82, in <module>
import pydevconsole
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.2.3\helpers\pydev\pydevconsole.py", line 23, in <module>
fix_getpass.fix_getpass()
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.2.3\helpers\pydev\_pydev_bundle\fix_getpass.py", line 3, in fix_getpass
import getpass
File "C:\Users\Name\AppData\Local\Programs\Python\Python37-32\lib\getpass.py", line 173, in <module>
import termios
File "C:\Users\Name\AppData\Local\Programs\Python\Python37-32\termios.py", line 73
IGNBRK = 0000001
^
SyntaxError: invalid token
Process finished with exit code 1
Hi Alex 0,
Could you please clarify how you installed python interpreter on your machine?
Looks like problem related to termios.
Hi Sergey,
thank you for coming back to me.
The installation was quite straight forward - i.e.
I've installed the latest Python 3.7.0 from this link:
https://www.python.org/downloads/release/python-370/
Then I've installed the latest PyCharm Community edition from this link:
https://www.jetbrains.com/pycharm/download/#section=windows
I left the settings and directories at offered default. In PyCharm I've created a new project and pointed to the installed "python.exe" interpreter.
I have Windows10 PRO EN (x64).
As mentioned previously a simple programs print("message") runs fine, but I got an error above when I tried to debug it.
In addition I've installed the latest Python 2.7.5 and did not experienced any problem during run and also debug.
Thank you for the update.
1) Please uncheck "Run with Python console" in your Run/Debug Configuration and try again.
2) Try as described here https://youtrack.jetbrains.com/issue/PY-28457#focus=streamItem-27-2706036-0-0
Please let me know the result.
Hi Alex,
I had the same problem you reported and just found a quick fix.
I had Anaconda 2 and Anaconda 3 installed, so I decided to organize things here doing the following:
- I removed Anaconda 2 folder on Windows Explorer
- created a new virtual env (on Windows Prompt type: conda create -n py37 python=3.7.0)
- on PyCharm, went to File >> Settings (CTRL+ALT+S) >> Project Interpreter >> Show All >> "+" button >> added the new python.exe interpreter from the virtual env
- on PyCharm, upper right corner of the screen, clicked on the drop down menu on the script's file name >> Edit Configuration >> Python Interpreter (selected the interpreter from the Virtual Env I just created)
And it worked.
I hope this helps.
@ Sergey Karpov
Hi Sergey,
add 1) The "Run with Python console" was already unchecked before (default setting).
add 2) I tried to set
PYDEVD_USE_CYTHON=NO
andPYDEVD_USE_FRAME_EVAL=NO
environment variable in the corresponding run configuration, but it also did not help. Please find the screenshot with and without variable modification below.Hi, honestly this line
is super confusing, there should simply be no termios module on windows and I have no idea at this point where it comes from. Do you have something like Cygwin installed? Could you please remove or rename
file? This way import termios in getpass will correctly fail and execution will proceed.
@ Pavel Karateev
Renaming termios.py helped. Thanks! I can now also debug the code.
I have just a fresh Python + PyCharm installation. Nothing like Cygwin was installed in addition.
Not sure if this a clean solution, but most importantly it works now. :)
I am using Anaconda with PyCharm Community 2018.2.4 (latest version) on a Windows 10 machine. I also experience this problem: normal run works fine, while debugging results in "Process finished with exit code -1073741819 (0xC0000005)" and no ability to debug.
I have done a file search for "termios.py" in both my AppData-folder (and all sub-directories) as well as my Anaconda-folder (and all sub-directories) without finding the named file. So I am still stuck with no debugging which is a pain.
Hope someone can help?
Hi Henrik, I think it's a different problem. Could you please add PYDEVD_USE_CYTHON=NO and PYDEVD_USE_FRAME_EVAL=NO environment variables to the run configuration you are using for debugging? Has it helped? Please feel free to create a new ticket in our bug tracker https://youtrack.jetbrains.com/issues/PY
Is it possible for you to share the project or a relevant part of it with us? Please also specify the Python version you are using.
Dear Pavel, Thank you for getting back so quickly! Would you prefer that I create a new ticket in the bug-tracking system?
In the meantime, to answer your question about the two mentioned environment variables: it didn't help.
The actual code resides in is a simple "dummy" project I created to test the debugging:
>Regarding your final question, currently I am using Python 3.6.
Could you please open Python Console in PyCharm and copy Python version line from it? I wonder which build version is it.
>Would you prefer that I create a new ticket in the bug-tracking system?
YouTrack has better formatting tools and the OPs' problem is different anyway.
Hi Pavel,
I have create an "issue" on YouTracker: PY-32051 Debugging not working in PyCharm Community 21018.2.4
I have also pasted my Python Console print-out into this ticket.
Kind regards,
Henrik
This issue is over 4 months old and not solved...
I rely on a working IDE. I pay for it and it's not usable for me. Since you introduced the DataScience "gimmicks" in the IDE I ran into a whole lot of issues I didn't have before.
Pardon for the rant, but I except that BASIC features such as debugging to work in an IDE. An IDE should support the programmer in working more efficient and not solving problems that would not arise if using another IDE. The quality of PyCharm got worse over the last 3 years and I really consider cancelling my subscription.... The support is really not there either: "please try this and that after several weeks...." - sorry, but if debuggin is not working, i can go back using vim or any other text editor with syntax highlight and autocomplete....
Hi Markus,
I am sincerely sorry for all the inconvenience. Does your problem related to https://youtrack.jetbrains.com/issue/PY-32051?
If yes, then as I can see it should be fixed in the latest PyCharm version.
This bug still happens in version 2019.1.2 (profession edition)
Any chance this will be fixed anytime soon?
Hi Gregg,
Could you please provide some code snippet for reproducing and let us know your Python version?
I facing the same problem in Intellji 2019.1 for python it only says "Connection to python debugger failed: socket closed"
M using Python 2.7 and OS is MACOS Mojave.
M using PYCharm 2019.2.3 .
I am also not able to debug the code in PYCHARM but its working fine in run mode. I have set the environment variable 'PYDEVD_USE_CYTHON=NO' but nothing seems working.
Here is the error trace of my debug mode.:
Testing started at 12:19 PM ...
/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 "/Applications/PyCharm CE.app/Contents/helpers/pydev/pydevd.py" --multiproc --qt-support=pyside2 --client 127.0.0.1 --port 57311 --file "/Applications/PyCharm CE.app/Contents/helpers/pycharm/_jb_pytest_runner.py" --path /Users/sayanisengupta/Desktop/XAJS_Automation_Latest/sample/tests/test_xajs.py
pydev debugger: process 2419 is connecting
Connected to pydev debugger (build 192.6817.19)
Launching pytest with arguments /Users/sayanisengupta/Desktop/XAJS_Automation_Latest/sample/tests/test_xajs.py in /Users/sayanisengupta/Desktop/XAJS_Automation_Latest/sample/tests
============================= test session starts ==============================
platform darwin -- Python 2.7.17, pytest-4.6.6, py-1.8.0, pluggy-0.13.0 -- /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
cachedir: .pytest_cache
rootdir: /Users/sayanisengupta/Desktop/XAJS_Automation_Latest/sample/tests
plugins: allure-pytest-2.8.6
collecting ...
test_xajs.py:None (test_xajs.py)
test_xajs.py:5: in <module>
import atomac.ldtp as ldtp
build/bdist.macosx-10.9-x86_64/egg/atomac/ldtp/__init__.py:550: in <module>
???
build/bdist.macosx-10.9-x86_64/egg/atomac/ldtp/__init__.py:227: in _populateNamespace
???
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py:1243: in __call__
return self.__send(self.__name, args)
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py:1602: in __request
verbose=self.__verbose
build/bdist.macosx-10.9-x86_64/egg/atomac/ldtp/client.py:144: in request
???
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py:1459: in send_content
connection.endheaders(request_body)
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py:1065: in endheaders
self._send_output(message_body)
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py:892: in _send_output
self.send(msg)
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py:854: in send
self.connect()
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py:831: in connect
self.timeout, self.source_address)
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py:575: in create_connection
raise err
E error: [Errno 61] Connection refused
collected 0 items / 1 errors
==================================== ERRORS ====================================
________________________ ERROR collecting test_xajs.py _________________________
test_xajs.py:5: in <module>
import atomac.ldtp as ldtp
build/bdist.macosx-10.9-x86_64/egg/atomac/ldtp/__init__.py:550: in <module>
???
build/bdist.macosx-10.9-x86_64/egg/atomac/ldtp/__init__.py:227: in _populateNamespace
???
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py:1243: in __call__
return self.__send(self.__name, args)
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py:1602: in __request
verbose=self.__verbose
build/bdist.macosx-10.9-x86_64/egg/atomac/ldtp/client.py:144: in request
???
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py:1459: in send_content
connection.endheaders(request_body)
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py:1065: in endheaders
self._send_output(message_body)
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py:892: in _send_output
self.send(msg)
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py:854: in send
self.connect()
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py:831: in connect
self.timeout, self.source_address)
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py:575: in create_connection
raise err
E error: [Errno 61] Connection refused
!!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!!
=========================== 1 error in 15.94 seconds ===========================
Process finished with exit code 0
Assertion failed
Assertion failed
Assertion failed
Assertion failed
Kindly help me on the same.
> E error: [Errno 61] Connection refused
Please try disabling any firewall/security software you might have, it looks like something is blocking the connection.
I had a similar issue. For me, .idea/workspace.xml had a problem in the RunManager component - SCRIPT_NAME was not set to the value I had specified through the GUI. I altered it to point to the correct script. That fixed the problem.
I had to rename inspect.py file in my project's home directory. Then debugger started working,
hi can anybody help me?
my pc is throwing this error when i click debugging in Pycharm IDE
A lot of the launch command string is not captured by the screenshot. Could you provide the full launch command as you see it in PyCharm?
I'm a little concerned by the io.py file being in venv root.
here is complete one though
C:\Users\Ahmed\PycharmProjects\untitled\venv\Scripts\python.exe "C:\Program Files\JetBrains\PyCharm Community Edition 2019.3.3\plugins\python-ce\helpers\pydev\pydevd.py" --multiproc --qt-support=auto --client 127.0.0.1 --port 4520 --file C:/Users/Ahmed/PycharmProjects/untitled/venv/io.py
Fatal Python error: init_sys_streams: can't initialize sys standard streams
Python runtime state: core initialized
Traceback (most recent call last):
File "C:/Users/Ahmed/PycharmProjects/untitled/venv\io.py", line 1, in <module>
File "C:\Users\Ahmed\AppData\Local\Programs\Python\Python38-32\lib\turtle.py", line 111, in <module>
File "C:\Users\Ahmed\AppData\Local\Programs\Python\Python38-32\lib\inspect.py", line 40, in <module>
File "C:\Users\Ahmed\AppData\Local\Programs\Python\Python38-32\lib\linecache.py", line 11, in <module>
File "C:\Users\Ahmed\AppData\Local\Programs\Python\Python38-32\lib\tokenize.py", line 27, in <module>
ImportError: cannot import name 'open' from 'builtins' (unknown location)
Your script path is C:/Users/Ahmed/PycharmProjects/untitled/venv/io.py , which has two issues:
- User scripts should not be inside venv directory
- io.py may shadow the name from another scope
Steps to fix:
1. Remove current run/debug configuration
2. Move io.py to C:/Users/Ahmed/PycharmProjects/untitled/
3. Rename io.py to something else, e.g. app.py
4. Create a new run/debug configuration and run.
I have this problem in 2020.
I tried different project interpreters, Anaconda, Virtual Environment, and different Python versions.
I am on Mac OS 10.15 and using PyCharm Professional 2020.1.
Please help.
Edit: I was actually able to solve this with the following stackoverflow thread: https://stackoverflow.com/questions/61696180/pytest-exec-code-in-self-locals-syntaxerror-missing-parentheses-in-call-to-exe
I had a folder named 'code' in my project. After renaming it, the debugger started working. Very weird.
Using PyCharm 2020.2 Python 3.8.5 - I had the same problem and found that anything named Code causes this problem. I had a very simple 1 file test project and it would never debug. Very simple fix:
I had this line...
Code = eventDict['Code']
Changed to this line...
DoorCode = eventDict['Code']
Now it works
I don't know if this will help anyone in the future but I experience the same issue. In my case I had a file named queue.py in my project.
Once I renamed that file the debugger started to work again.