Python Forum
Running a python tool transforming xml files into epub files - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Running a python tool transforming xml files into epub files (/thread-10041.html)



Running a python tool transforming xml files into epub files - silfer - May-10-2018

Hello Smile

I found the python tool 'tei2epub' to transform TEI files (=standardized xml files) into epub files on the page https://code.google.com/archive/p/epub-tools/. I downloaded:

- tei2epub-1.0b.zip on page https://code.google.com/archive/p/epub-tools/downloads
- http://www.bvh.univ-tours.fr/XML-TEI/Manuel_TEI_BVH.tei.xml which is a TEI-file to be transformed

I failed getting a result (I am using Pycharm Community). Being new at Python, would be someone interested to try to run this tool and first confirm me that it works? If yes, I will ask for some help so that I can get the same success...

Thanks!

Silfer


RE: Running a python tool transforming xml files into epub files - silfer - May-10-2018

No answer at the moment Sleepy

Maybe some of you are thinking: 'Well, man, just learn the language! Just learn how to run it!'

Well, you're right...

I made some steps further Smile in reading README (huge effort):

Quote:To test your tei2epub installation, run:
bin/tei2epub.py sample/Wuthering-Heights_Emily-Bronte.xml
If all goes well it will say:
"No errors or warnings were detected"
(that's validation from epubcheck)
and there will be a Wuthering-Heights_Emily-Bronte.epub in the 'dist'
folder.


I tried a run and got these error messages:

Error:
Traceback (most recent call last): File "some_path/tei2epub.py", line 167, in <module> sys.exit(convert(*sys.argv)) File "some_path/tei2epub.py", line 151, in convert create_navmap(path, tree) File "some_path/tei2epub.py", line 72, in create_navmap _output_xml(f, processed) File "some_path/tei2epub.py", line 77, in _output_xml content.write(etree.tostring(xml, encoding='utf-8', pretty_print=True, xml_declaration=True)) TypeError: write() argument must be str, not bytes
So, what? What corrections should I make? Huh


RE: Running a python tool transforming xml files into epub files - buran - May-10-2018

what version of python do you use?


RE: Running a python tool transforming xml files into epub files - silfer - May-10-2018

Python 3.6


RE: Running a python tool transforming xml files into epub files - buran - May-10-2018

Well, I don't think this tool is for python3. Last update is 2010. It's very obsolete... It may not work even with latest python2...


RE: Running a python tool transforming xml files into epub files - silfer - May-10-2018

Thanks for your answer, buran.
I would not have thought about a python's version problem.
Date of tool: Nov 18, 2008 https://code.google.com/archive/p/epub-tools/downloads
It should work with python 2.6.0 https://www.python.org/downloads/
Is it trivial to download and work with 2 different versions of Python on the same machine?


RE: Running a python tool transforming xml files into epub files - buran - May-10-2018

yes, it's not a problem to have multiple version installed, though it could be a bit confusing for a newbie to install.
there are plenty of resources, e.g.
https://datascience.com.co/how-to-install-python-2-7-and-3-6-in-windows-10-add-python-path-281e7eae62a
but there are others, just google it.
If you are running it from PyCharm you will need to setup the correct interpreter for the project too.


RE: Running a python tool transforming xml files into epub files - snippsat - May-10-2018

(May-10-2018, 03:18 PM)silfer Wrote: Is it trivial to download and work with 2 different versions of Python on the same machine?
It's no problem,but don't add to windows Path if you get question about it.
Look at Python 3.6 and pip installation under Windows.
So now is 3.6 in Window Path,it also install a py.exe this is what you use to run other version.
If python and pip work from anywhere in cmd,so will also py.
Here a run of how it look.
Microsoft Windows [Version 10.0.16299.431]
(c) 2017 Microsoft Corporation. Med enerett.

C:\Windows\System32>cd\

C:\>cd 1

C:\1>python -V
Python 3.6.4

C:\1>pip -V
pip 10.0.1 from c:\python36\lib\site-packages\pip (python 3.6)

C:\1>py -2.7 -V
Python 2.7.9

# Now run a .py file with 2.7
C:\1>py -2.7 version.py
Hello from 2.7.9 (default, Dec 10 2014, 12:24:55) [MSC v.1500 32 bit (Intel)]

# With 3.4
C:\1>py -3.4 version.py
Hello from 3.4.2 (v3.4.2:ab2c023a9432, Oct  6 2014, 22:15:05) [MSC v.1600 32 bit (Intel)]

# With 3.5
C:\1>py -3.5 version.py
Hello from 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:01:18) [MSC v.1900 32 bit (Intel)]

# With 3.6 which is the main version here use python
C:\1>python version.py
Hello from 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)]
C:\1>