3
I’m using the following code:
from docx import Document
d = Document(open("arquivo.docx"))
This code works on Ubuntu but does not work on windows.
In windows I have the return in the terminal:
Traceback (Most recent call last): File "Default2.py", line 94, in dialogo d = Document(f)
File "C: Python27 lib site-Packages docx api.py", line 35, in init document_part, package = self. _open(docx)
File "C: Python27 lib site-Packages docx api.py", line 193, in _open package = Package.open(docx)
File "C: Python27 lib site-Packages docx opc package.py", line 116, in open pkg_reader = PackageReader.from_file(pkg_file)
File "C: Python27 lib site-Packages docx opc pkgreader.py", line 32, in from_f ile
phys_reader = Physpkgreader(pkg_file) File "C: Python27 lib site-Packages docx opc phys_pkg.py", line 101, in __init __ self. _Zipf = Zipfile(pkg_file, 'r')
File "C: Python27 lib zipfile.py", line 793, in init self. _Realgetcontents()
File "C: Python27 lib zipfile.py", line 860, in _Realgetcontents raise Badzipfile("Truncated central directory") zipfile.Badzipfile: Truncated central directory
The complete code is at that link
@Math his answer helped me a lot. However, it was not the right one, but it gives me paths where I should continue researching. Anyway I changed to the form that served to min. Thank you.
– Murilo Ferro
@Muriloferro you can post your own answer explaining what you did to solve, if you think it’s worth explaining.
– Math
Excellent response.
– YanSym