Python Forum
Running a python tool transforming xml files into epub files
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Running a python tool transforming xml files into epub files
#1
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/Man...VH.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
Reply
#2
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
Reply
#3
what version of python do you use?
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#4
Python 3.6
Reply
#5
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...
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#6
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?
Reply
#7
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-instal...81e7eae62a
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.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#8
(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>
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Is it possible to extract 1 or 2 bits of data from MS project files? cubangt 8 945 Feb-16-2024, 12:02 AM
Last Post: deanhystad
  File loop curiously skipping files - FIXED mbk34 10 685 Feb-10-2024, 07:08 AM
Last Post: buran
  Copy Paste excel files based on the first letters of the file name Viento 2 348 Feb-07-2024, 12:24 PM
Last Post: Viento
  Class test : good way to split methods into several files paul18fr 4 403 Jan-30-2024, 11:46 AM
Last Post: Pedroski55
  uploading files from a ubuntu local directory to Minio storage container dchilambo 0 400 Dec-22-2023, 07:17 AM
Last Post: dchilambo
  Upload Files to Azure Storage Container phillyfa 6 581 Dec-22-2023, 06:11 AM
Last Post: Pedroski55
  python convert multiple files to multiple lists MCL169 6 1,436 Nov-25-2023, 05:31 AM
Last Post: Iqratech
  merge all xlsb files into csv mg24 0 303 Nov-13-2023, 08:25 AM
Last Post: mg24
  Newbie question about switching between files - Python/Pycharm Busby222 3 543 Oct-15-2023, 03:16 PM
Last Post: deanhystad
  Move Files based on partial Match mohamedsalih12 2 746 Sep-20-2023, 07:38 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020