running fine but while debugging getting an error "ModuleNotFoundError: No module named 'xml.parsers'; 'xml' is not a package"

Answered

while i try to debugging in pycharm i got that error. I am using python 3.7 . I tried reinstallation of python and pycharm but invain

 

0
8 comments

Hi,

What is the name of the file?

Would be great to see the whole console output.

0
Avatar
Permanently deleted user

I am also getting this error.

PyCharm 2019.3.4 (Community Edition)
Build #PC-193.6911.25, built on March 18, 2020
Runtime version: 11.0.6+8-b520.43 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
GC: ParNew, ConcurrentMarkSweep
Memory: 1953M
Cores: 8
Registry:
Non-Bundled Plugins: amailp.intellij.robot, com.millennialmedia.intellibot, io.github.qeesung.component.HighlightBracketPair

Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.3.3\plugins\python-ce\helpers\pydev\pydevd.py", line 20, in <module>
    from _pydevd_bundle.pydevd_constants import IS_JYTH_LESS25, IS_PYCHARM, get_thread_id, get_current_thread_id, \
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.3.3\plugins\python-ce\helpers\pydev\_pydevd_bundle\pydevd_constants.py", line 202, in <module>
    from _pydev_imps._pydev_saved_modules import thread
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.3.3\plugins\python-ce\helpers\pydev\_pydev_imps\_pydev_saved_modules.py", line 21, in <module>
    import xmlrpc.client as xmlrpclib
  File "C:\Users\sean.talbot\AppData\Local\Programs\Python\Python38-32\lib\xmlrpc\client.py", line 138, in <module>
    from xml.parsers import expat
ModuleNotFoundError: No module named 'xml.parsers'; 'xml' is not a package
 
Process finished with exit code 1
 
Empty suite
 
Empty suite

 

 

 

0
Avatar
Permanently deleted user

Another:

 

Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.3.3\plugins\python-ce\helpers\pycharm\_jb_pytest_runner.py", line 7, in <module>
from pkg_resources import iter_entry_points
File "C:\VirtualEnvironment\App2\lib\site-packages\pkg_resources\__init__.py", line 35, in <module>
import plistlib
File "C:\Users\sean.talbot\AppData\Local\Programs\Python\Python38-32\lib\plistlib.py", line 65, in <module>
from xml.parsers.expat import ParserCreate
ModuleNotFoundError: No module named 'xml.parsers'; 'xml' is not a package

0
Avatar
Permanently deleted user

Sorry for the triple post, but I've just updated to the new version and it's still happening.

 

Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.3.3\plugins\python-ce\helpers\pycharm\_jb_pytest_runner.py", line 7, in <module>
    from pkg_resources import iter_entry_points
  File "C:\VirtualEnvironment\App2\lib\site-packages\pkg_resources\__init__.py", line 35, in <module>
    import plistlib
  File "C:\Users\sean.talbot\AppData\Local\Programs\Python\Python38-32\lib\plistlib.py", line 65, in <module>
    from xml.parsers.expat import ParserCreate
ModuleNotFoundError: No module named 'xml.parsers'; 'xml' is not a package
 
Process finished with exit code 1
 
Empty suite

 

0

Please try running your code from the terminal outside of IDE, to see if it's IDE's fault

For more information on how to run your code from the terminal outside of IDE, please see the following article:
https://docs.python.org/3/using/cmdline.html#command-line

If you're using virtualenv interpreter in PyCharm, you may need to activate it in the command line as well:
https://virtualenv.pypa.io/en/latest/user_guide.html#activators

0
Avatar
Permanently deleted user

Hi Andrey, thanks for your reply. pytest works fine when I activate the virtual environment and run it, via the command line.

 

Additionally, the 'run Pytest in <test_dir>' command in PyCharm shows this command in the Run console:

C:\VirtualEnvironment\App2\Scripts\python.exe "C:\Program Files\JetBrains\PyCharm Community Edition 2019.3.3\plugins\python-ce\helpers\pycharm\_jb_pytest_runner.py" --path C:/Users/sean.talbot/Documents/github/App2/store/store/tests/functional

 

That fails with the same "ModuleNotFoundError: No module named 'xml.parsers'; 'xml' is not a package" error in Pycharm. But when I run that command in cmd.exe, after activating the virtual environment, it works. 

0

That means something is probably wrong with the environment. Please run the following snippet both in PyCharm, and from the terminal in the same environment:

https://gist.github.com/aresler/22c59d7883fd57dddb4c57a7f96603d6

Compare the outputs (if possible, provide both of them here). One more thing - when we see errors like "No module named 'xml.parsers'; 'xml' is not a package", it is often caused by name shadowing. Make sure you don't have your own files/functions/methods named "xml"

0

In my case I got the same error from a slightly different stacktrace:

/Users/skerr/Documents/Development/genshare_service_github/venv/bin/python3.9 /Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py --multiprocess --qt-support=auto --client 127.0.0.1 --port 50443 --file /Users/skerr/Documents/Development/genshare_service_github/main.py Traceback (most recent call last): File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py", line 16, in <module> from _pydevd_bundle.pydevd_collect_try_except_info import collect_return_info File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydevd_bundle/pydevd_collect_try_except_info.py", line 12, in <module> from _pydevd_bundle.pydevd_constants import IS_PY38_OR_GREATER File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydevd_bundle/pydevd_constants.py", line 230, in <module> from _pydev_imps._pydev_saved_modules import thread File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/_pydev_imps/_pydev_saved_modules.py", line 21, in <module> import xmlrpc.client as xmlrpclib File "/Users/skerr/.pyenv/versions/3.9.19/lib/python3.9/xmlrpc/client.py", line 138, in <module> from xml.parsers import expat ModuleNotFoundError: No module named 'xml.parsers'

The root cause I believe was a corrupted launch configuration.

I found that some non-Flask scripts were succeeding in attaching the debugger.

I took one of those launchers and copied it. I edited the script to launch, the venv/interpreter and the working folder to match the failing launcher.

It worked.



 

0

Please sign in to leave a comment.