pbs / pycaption

Python module to read/write popular video caption formats
Apache License 2.0
256 stars 136 forks source link

ImportError: cannot import name BaseWriter #35

Closed schroka1 closed 9 years ago

schroka1 commented 10 years ago

Using test.py with the code below. I'm trying to get the transcript (What I want to use the script for). Am I missing something? This is running on windows with Python 2.7 If I leave out the transcript it work fine.

from pycaption import SRTReader, SAMIWriter, DFXPWriter, transcript

srt_caps = '''1 00:00:09,209 --> 00:00:12,312 This is an example SRT file, which, while extremely short, is still a valid SRT file. '''

converter = CaptionConverter() converter.read(srt_caps, SRTReader()) print converter.write(SAMIWriter()) print converter.write(DFXPWriter()) print converter.write(pycaption.transcript.TranscriptWriter())

I keep getting the error

Traceback (most recent call last): File "C:\Python27\pycaption-master\test.py", line 3, in from pycaption import SRTReader, SAMIWriter, DFXPWriter, transcript File "C:\Python27\pycaption-master\pycaption\transcript.py", line 7, in from pycaption import BaseWriter, CaptionNode ImportError: cannot import name BaseWriter

I think CaptionNode will fail as well.

Are they missing from the build? Is there another requirement?

Here is the build and error.

C:\Python27\pycaption-master>C:\Python27\pycaption-master\setup.py install running install running bdist_egg running egg_info creating pycaption.egg-info writing requirements to pycaption.egg-info\requires.txt writing pycaption.egg-info\PKG-INFO writing top-level names to pycaption.egg-info\top_level.txt writing dependency_links to pycaption.egg-info\dependency_links.txt writing manifest file 'pycaption.egg-info\SOURCES.txt' reading manifest file 'pycaption.egg-info\SOURCES.txt' reading manifest template 'MANIFEST.in' writing manifest file 'pycaption.egg-info\SOURCES.txt' installing library code to build\bdist.win32\egg running install_lib running build_py creating build creating build\lib creating build\lib\pycaption copying pycaption\base.py -> build\lib\pycaption copying pycaption\dfxp.py -> build\lib\pycaption copying pycaption\exceptions.py -> build\lib\pycaption copying pycaption\sami.py -> build\lib\pycaption copying pycaption\scc.py -> build\lib\pycaption copying pycaption\srt.py -> build\lib\pycaption copying pycaption\transcript.py -> build\lib\pycaption copying pycaption\webvtt.py -> build\lib\pycaption copying pycaptioninit.py -> build\lib\pycaption creating build\lib\tests copying tests\mixins.py -> build\lib\tests copying tests\samples.py -> build\lib\tests copying tests\test_dfxp.py -> build\lib\tests copying tests\test_dfxp_conversion.py -> build\lib\tests copying tests\test_sami.py -> build\lib\tests copying tests\test_sami_conversion.py -> build\lib\tests copying tests\test_scc.py -> build\lib\tests copying tests\test_scc_conversion.py -> build\lib\tests copying tests\test_srt.py -> build\lib\tests copying tests\test_srt_conversion.py -> build\lib\tests copying tests\test_webvtt.py -> build\lib\tests copying tests\test_webvtt_conversion.py -> build\lib\tests copying testsinit.py -> build\lib\tests copying pycaption\english.pickle -> build\lib\pycaption creating build\bdist.win32 creating build\bdist.win32\egg creating build\bdist.win32\egg\pycaption copying build\lib\pycaption\base.py -> build\bdist.win32\egg\pycaption copying build\lib\pycaption\dfxp.py -> build\bdist.win32\egg\pycaption copying build\lib\pycaption\english.pickle -> build\bdist.win32\egg\pycaption copying build\lib\pycaption\exceptions.py -> build\bdist.win32\egg\pycaption copying build\lib\pycaption\sami.py -> build\bdist.win32\egg\pycaption copying build\lib\pycaption\scc.py -> build\bdist.win32\egg\pycaption copying build\lib\pycaption\srt.py -> build\bdist.win32\egg\pycaption copying build\lib\pycaption\transcript.py -> build\bdist.win32\egg\pycaption copying build\lib\pycaption\webvtt.py -> build\bdist.win32\egg\pycaption copying build\lib\pycaptioninit.py -> build\bdist.win32\egg\pycaption creating build\bdist.win32\egg\tests copying build\lib\tests\mixins.py -> build\bdist.win32\egg\tests copying build\lib\tests\samples.py -> build\bdist.win32\egg\tests copying build\lib\tests\test_dfxp.py -> build\bdist.win32\egg\tests copying build\lib\tests\test_dfxp_conversion.py -> build\bdist.win32\egg\tests copying build\lib\tests\test_sami.py -> build\bdist.win32\egg\tests copying build\lib\tests\test_sami_conversion.py -> build\bdist.win32\egg\tests copying build\lib\tests\test_scc.py -> build\bdist.win32\egg\tests copying build\lib\tests\test_scc_conversion.py -> build\bdist.win32\egg\tests copying build\lib\tests\test_srt.py -> build\bdist.win32\egg\tests copying build\lib\tests\test_srt_conversion.py -> build\bdist.win32\egg\tests copying build\lib\tests\test_webvtt.py -> build\bdist.win32\egg\tests copying build\lib\tests\test_webvtt_conversion.py -> build\bdist.win32\egg\tests copying build\lib\testsinit.py -> build\bdist.win32\egg\tests byte-compiling build\bdist.win32\egg\pycaption\base.py to base.pyc byte-compiling build\bdist.win32\egg\pycaption\dfxp.py to dfxp.pyc byte-compiling build\bdist.win32\egg\pycaption\exceptions.py to exceptions.pyc byte-compiling build\bdist.win32\egg\pycaption\sami.py to sami.pyc byte-compiling build\bdist.win32\egg\pycaption\scc.py to scc.pyc byte-compiling build\bdist.win32\egg\pycaption\srt.py to srt.pyc byte-compiling build\bdist.win32\egg\pycaption\transcript.py to transcript.pyc byte-compiling build\bdist.win32\egg\pycaption\webvtt.py to webvtt.pyc byte-compiling build\bdist.win32\egg\pycaptioninit.py to init.pyc byte-compiling build\bdist.win32\egg\tests\mixins.py to mixins.pyc byte-compiling build\bdist.win32\egg\tests\samples.py to samples.pyc byte-compiling build\bdist.win32\egg\tests\test_dfxp.py to test_dfxp.pyc byte-compiling build\bdist.win32\egg\tests\test_dfxp_conversion.py to test_dfxp_conversion.pyc byte-compiling build\bdist.win32\egg\tests\test_sami.py to test_sami.pyc byte-compiling build\bdist.win32\egg\tests\test_sami_conversion.py to test_sami_conversion.pyc byte-compiling build\bdist.win32\egg\tests\test_scc.py to test_scc.pyc byte-compiling build\bdist.win32\egg\tests\test_scc_conversion.py to test_scc_conversion.pyc byte-compiling build\bdist.win32\egg\tests\test_srt.py to test_srt.pyc byte-compiling build\bdist.win32\egg\tests\test_srt_conversion.py to test_srt_conversion.pyc byte-compiling build\bdist.win32\egg\tests\test_webvtt.py to test_webvtt.pyc byte-compiling build\bdist.win32\egg\tests\test_webvtt_conversion.py to test_webvtt_conversion.pyc byte-compiling build\bdist.win32\egg\testsinit.py to init.pyc creating build\bdist.win32\egg\EGG-INFO copying pycaption.egg-info\PKG-INFO -> build\bdist.win32\egg\EGG-INFO copying pycaption.egg-info\SOURCES.txt -> build\bdist.win32\egg\EGG-INFO copying pycaption.egg-info\dependency_links.txt -> build\bdist.win32\egg\EGG-INFO copying pycaption.egg-info\requires.txt -> build\bdist.win32\egg\EGG-INFO copying pycaption.egg-info\top_level.txt -> build\bdist.win32\egg\EGG-INFO zip_safe flag not set; analyzing archive contents... pycaption.transcript: module references file creating dist creating 'dist\pycaption-0.3.6-py2.7.egg' and adding 'build\bdist.win32\egg' to it removing 'build\bdist.win32\egg' (and everything under it) Processing pycaption-0.3.6-py2.7.egg removing 'c:\python27\lib\site-packages\pycaption-0.3.6-py2.7.egg' (and everything under it) creating c:\python27\lib\site-packages\pycaption-0.3.6-py2.7.egg Extracting pycaption-0.3.6-py2.7.egg to c:\python27\lib\site-packages pycaption 0.3.6 is already the active version in easy-install.pth

Installed c:\python27\lib\site-packages\pycaption-0.3.6-py2.7.egg Processing dependencies for pycaption==0.3.6 Searching for cssutils==1.0 Best match: cssutils 1.0 Processing cssutils-1.0-py2.7.egg cssutils 1.0 is already the active version in easy-install.pth Installing csscombine-script.py script to C:\Python27\Scripts Installing csscombine.exe script to C:\Python27\Scripts Installing csscombine.exe.manifest script to C:\Python27\Scripts Installing cssparse-script.py script to C:\Python27\Scripts Installing cssparse.exe script to C:\Python27\Scripts Installing cssparse.exe.manifest script to C:\Python27\Scripts Installing csscapture-script.py script to C:\Python27\Scripts Installing csscapture.exe script to C:\Python27\Scripts Installing csscapture.exe.manifest script to C:\Python27\Scripts

Using c:\python27\lib\site-packages\cssutils-1.0-py2.7.egg Searching for lxml==3.3.5 Best match: lxml 3.3.5 Processing lxml-3.3.5-py2.7-win32.egg lxml 3.3.5 is already the active version in easy-install.pth

Using c:\python27\lib\site-packages\lxml-3.3.5-py2.7-win32.egg Searching for beautifulsoup4==4.3.2 Best match: beautifulsoup4 4.3.2 Processing beautifulsoup4-4.3.2-py2.7.egg beautifulsoup4 4.3.2 is already the active version in easy-install.pth

Using c:\python27\lib\site-packages\beautifulsoup4-4.3.2-py2.7.egg Finished processing dependencies for pycaption==0.3.6

C:\Python27\pycaption-master>test.py Traceback (most recent call last): File "C:\Python27\pycaption-master\test.py", line 3, in from pycaption import SRTReader, SAMIWriter, DFXPWriter, transcript File "C:\Python27\pycaption-master\pycaption\transcript.py", line 7, in from pycaption import BaseWriter, CaptionNode ImportError: cannot import name BaseWriter

vladiibine commented 9 years ago

was fixed in pull request #121