Module 'xml.dom' has no attribute 'Node' - python

I wanted to use the module xml in Python 3.7, however i am getting the following error :
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> from xml.dom import minidom
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
from xml.dom import minidom
File "C:\Users\EMurairi18\AppData\Local\Programs\Python\Python37-32\lib\xml\dom\minidom.py", line 30, in <module>
_nodeTypes_with_children = (xml.dom.Node.ELEMENT_NODE,
AttributeError: module 'xml.dom' has no attribute 'Node'
>>>
What is wrong with this ?

Tried to replicate the error installing python3.7.0, but it's all working fine. Maybe there were conflicting packages in that installation (which could be prevented by managing dependencies within a python virtual environment, or any similar option), or maybe the issue is fixed if there was any.

Related

Can't import cElementTree on Python 2.7

I cannot import xml.etree.cElementTree on Python 2.7. On the web, it says its already implemented, so I don't have to install it. (It's working on Python 3.6 for me, but I need 2.7 for reasons here)
Thats the console output:
Python 2.7.15+ (default, Nov 27 2018, 23:36:35)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import xml.etree.cElementTree
Failed to import cElementTree from any known place
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named etree.cElementTree
I hope you can help me.
Kind regards,
Markus
I just found out that theres an old xml.pyc file in that directory, which didnt show up in PyCharm. It stopped the "real" XML from loading.

Python 3: No module named 'AudioSignal'

The code below gives this error when I'm trying to execute it:
>>> import nussl
>>> history = nussl.AudioSignal('HistoryRepeatingPropellerHeads.wav')
Error is:
C:\Users\MyPCUser>python
Python 3.7.1 (v3.7.1:260ec2c36a, Oct 20 2018, 14:57:15) [MSC v.1915 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import nussl
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\MyPCUser\AppData\Local\Programs\Python\Python37\lib\site-packages\nussl\__init__.py", line 26, in <modul
e>
from .core.constants import *
File "C:\Users\MyPCUser\AppData\Local\Programs\Python\Python37\lib\site-packages\nussl\core\__init__.py", line 7, in <m
odule>
from audio_signal import AudioSignal
ModuleNotFoundError: No module named 'audio_signal'
>>>
This module does not work yet (23-Feb-2019) with Python 3 according to Issue 135 and Issue 133. From the docs: This package has been tested with python 2.7, but not python 3.x yet. Use python 3 at your own peril!
I got the same issue when trying to use it with Python 3.

How to run PDFbookmarker in Python

I am trying to use this tool https://github.com/RussellLuo/pdfbookmarker but I am constantly given with error messages.
I installed portable WinPython, installed PyPDF2 via pip, downloaded add_bookmarks.py script and pasted it into WinPython catalogue, changed its execute rights, and just can't run it properly, why?
Python 3.5.4 (v3.5.4:3f56838, Aug 8 2017, 02:17:05) [MSC v.1900 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> add_bookmarks.py <test.pdf> [sample_bookmarks.txt] [FILE-new.pdf]
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
add_bookmarks.py <test.pdf> [sample_bookmarks.txt] [FILE-new.pdf]
NameError: name 'add_bookmarks' is not defined
>>>
Eventually I used another one: https://github.com/lstolcman/pdf_bookmarks and it worked.

Python 3 cannot import socket in CMD but available in IDLE

I have installed python 3.7 on my computer. It seems not possible to import socket in CMD:
C:\Users\Sina\py
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python37-32\lib\socket.py", line 49, in <module>
import _socket
ImportError: Module use of python27.dll conflicts with this version of
Python.
>>>
But surprisingly, I am able to import socket in IDLE (Python 3.7).
I searched but didn't find any 'python27.dll' file in the installation directory
of python 3.7 (C:\Python37-32)
EDIT: There was a _socket.pyd file at "C:\Users\Sina" which used to make the confliction. I deleted it and the problem got fixed. Thanks to Aran-Fey!

“ImportError: No module named scipy” after installing the scipy package

I need help with the scipy Python module. I installed it, but when I try to import it, I get an error (no module named scipy). Why?
Here's the output from my Python interpreter:
Python 2.7.8 (default, Jun 30 2014, 16:08:48) [MSC v.1500 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import scipy
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import scipy
ImportError: No module named scipy

Categories