Getting this error while using epub python package or you can say epub library for python , wondering what to do about it. please help..
Traceback (most recent call last):
File "F:/4th semester/3", line 4, in <module>
book=epub.open_epub('d:\welcome.epub')
File "C:\Python27\lib\site-packages\epub\__init__.py", line 43, in open_epub
return EpubFile(filename, mode)
File "C:\Python27\lib\site-packages\epub\__init__.py", line 82, in __init__
self._init_read()
File "C:\Python27\lib\site-packages\epub\__init__.py", line 143, in _init_read
self.toc = ncx.parse_toc(self.read_item(item_toc))
File "C:\Python27\lib\site-packages\epub\__init__.py", line 276, in read_item
return self.read(os.path.join(self.content_path, path))
File "C:\Python27\lib\zipfile.py", line 931, in read
return self.open(name, "r", pwd).read()
File "C:\Python27\lib\zipfile.py", line 957, in open
zinfo = self.getinfo(name)
File "C:\Python27\lib\zipfile.py", line 905, in getinfo
'There is no item named %r in the archive' % name)
KeyError: "There is no item named u'OEBPS\\toc.ncx' in the archive"enter code here
From your question I presume you are using Python-Epub library from here: https://pypi.python.org/pypi/epub/0.5.1 and you are running in Windows.
It helps to know that EPUBs are essentially zip files. A typical bug in Python EPUB-handling libraries is attempting to build paths inside zip archive with os.path.join as if it were regular file system. On Windows os.path.join squeezes Windows file path separators (i.e., \\) that are not recognized by zipfile module.
This is a bug in epub library (which should be reported) yet you can easily get a work-around as following:
Determine where your epub sources are located:
python -c "import epub; print epub.__file__"
Add the following function to epub sources:
def zip_path_join(a, *p):
for b in p:
a += '/' + b
return a
Search epub sources for os.path.join and replace it with zip_path_join
Enjoy!
Thanks for the report of the issue. This is... well... shame on me, I should have fixed that a long time ago.
So, I've pushed a new version 0.5.2, and you can upgrade your version and see if it works as you expect (it should, yet I didn't run unit-test on any Windows env).
PS: I won't say "I got a life and stuff happen", but... yeah, that's just it...
Related
Working on a project that uses pyexcel to read and write .xls files which is compiled using py2exe.
I get this error after compiling and confirming that pyexcel, pyexcel-io and pyexcel-xls are in the library.zip folder.
Traceback (most recent call last):
File "FundDatabase.pyo", line 391, in get_worksheet
File "pyexcel\core.pyo", line 118, in get_book
File "pyexcel\core.pyo", line 137, in _get_book
File "pyexcel\sources\file_source_input.pyo", line 52, in get_data
File "pyexcel_io\io.pyo", line 31, in get_data
File "pyexcel_io\io.pyo", line 118, in load_data_new
File "pyexcel_io\manager.pyo", line 94, in create_reader
File "pyexcel_io\manager.pyo", line 89, in _get_a_handler
IOError: No suitable library found for xls
here is my project library
Short Answer
You will need to tell pyinstaller about the hidden imports about pyexcel-xls.
In order to package pyexcel-xls, you need to specify:
--hidden-import pyexcel_xls
--hidden-import pyexcel_xls.xlsr
--hidden-import pyexcel_xls.xlsw
Reference: mechanism of dynamic load module, confilict with pyinstaller/cx_freeze's execution
Long Answer
Since version 0.5.0, pyexcel uses lazy loading, which creates a problem for pystaller because not all modules are loaded on program's startup. Hence, you will need to tell pyinstaller about the missing imports(a.k.a hidden imports).
Pyinstaller notes
http://pyexcel.readthedocs.io/en/latest/pyinstaller.html
http://pyexcel-io.readthedocs.io/en/latest/pyinstaller.html
I had already had sublime and when setting up new plug-ins, I found problem for the setup of SublimeClang. It requires libClang but I searched all my folders using the " locate clang" command and couln't find libclang at last (The doc on the web said it should be located in usr/lib/x86_64-linux-gnu/).
When i open the sublime, the console printed out like this:
Traceback (most recent call last):
File "/home/meng/.config/sublime-text-3/Packages/SublimeClang/internals/clang/cindex.py", line 95, in get_cindex_library
return cdll.LoadLibrary(filename)
File "./ctypes/__init__.py", line 431, in LoadLibrary
File "./ctypes/__init__.py", line 353, in __init__
OSError: libclang.so: cannot open shared object file: No such file or directory
error: It looks like libclang.so couldn't be loaded. You have to compile it yourself, or download from https://github.com/quarnster/SublimeClang/downloads.
Please note that this plugin uses features from clang 3.0 so make sure that is the version you have installed.
Once you have the file, you need to copy libclang.so into the root of this plugin. See http://github.com/quarnster/SublimeClang for more details.
I'm rookie in ubuntu OS and hope someone can give me help. Many thanks!
I'm trying to open a warc file with python using the toolbox from the following link:
http://warc.readthedocs.org/en/latest/
When opening the file with:
import warc
f = warc.open("00.warc.gz")
Everything is fine and the f object is:
<warc.warc.WARCFile instance at 0x1151d34d0>
However when I'm trying to read everything in the file using:
for record in f:
print record['WARC-Target-URI'], record['Content-Length']
The following error appears:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/xxx/anaconda/lib/python2.7/site-packages/warc/warc.py", line 390, in __iter__
record = self.read_record()
File "/Users/xxx/anaconda/lib/python2.7/site-packages/warc/warc.py", line 373, in read_record
header = self.read_header(fileobj)
File "/Users/xxx/anaconda/lib/python2.7/site-packages/warc/warc.py", line 331, in read_header
raise IOError("Bad version line: %r" % version_line)
IOError: Bad version line: 'WARC/0.18\n'
Is this because my warc file version is not supported by the warc toolbox I'm using or something else?
ClueWeb09 dataset is available in the WARC 0.18 format. However, it has several issues. Some records are malformed.
The most prevalent problem is an extra newline in the WARC header. There are a few cases of other malformed headers also.
Moreover, it does not use the standard \r\n end-of-line markers which is actually your problem.
warc-clueweb library can handle it. This is a special python library to work with ClueWeb09 WARC files. According to documentation
Only minor modifications to the original library were made. The original documentation of the warc library still holds
Yes, thanks for #eyelash explanation about this problem.
Actually some records in Clueweb-09 are malformed. But the official warc library and the above recommended git repo warc-clueweb library both have some issues.
This fork repo could not handle Clueweb12 dataset and another issue is that it could miss 1-2 document when dealing every .warc.gz file.
So I've changed a little code to support both Clueweb09 and Cluewe12 datasets. Here is my repo which has been tested on 100 billion pages, my warc tools forked and changed from warc-clueweb library and official repo.
This is the output of buildozer:
buildozer android debug
# Check configuration tokens
# Ensure build layout
# Check configuration tokens
# Preparing build
# Check requirements for android
# Install platform
# Apache ANT found at /root/.buildozer/android/platform/apache-ant-1.8.4
# Android SDK found at /root/.buildozer/android/platform/android-sdk-21
# Android NDK found at /root/.buildozer/android/platform/android-ndk-r9c
# Android packages already installed.
# Check application requirements
# Compile platform
# Distribution compiled.
# Build the application #1
# Package the application
Traceback (most recent call last):
File "/bin/buildozer", line 5, in <module>
run()
File "/usr/lib/python2.7/site-packages/buildozer/__init__.py", line 1215, in run
Buildozer().run_command(sys.argv[1:])
File "/usr/lib/python2.7/site-packages/buildozer/__init__.py", line 842, in run_command
self.target.run_commands(args)
File "/usr/lib/python2.7/site-packages/buildozer/target.py", line 85, in run_commands
func(args)
File "/usr/lib/python2.7/site-packages/buildozer/target.py", line 97, in cmd_debug
self.buildozer.build()
File "/usr/lib/python2.7/site-packages/buildozer/__init__.py", line 178, in build
self.target.build_package()
File "/usr/lib/python2.7/site-packages/buildozer/targets/android.py", line 397, in build_package
version = self.buildozer.get_version()
File "/usr/lib/python2.7/site-packages/buildozer/__init__.py", line 554, in get_version
' (looking for `{1}`)'.format(fn, regex))
Exception: Unable to find capture version in ./main.py
(looking for `__version__ = '(.*)'`)
I'm trying to compile a simple probability calculator I designed. I can't post the code, because I'm going to try to publish it. However, I'm willing to answer any questions I need to to get this to work.
Judging by the output of buildozer, I think it's looking for a line in main.py that I didn't know I needed. Unfortunately, I don't have any idea what that line would look like. However, in buildozer.spec, there is a line that says this:
version.regex = __version__ = '(.*)'
version.filename = %(source.dir)s/main.py
The first line looks like the line in the output and the second references the main.py file. Does anyone know what these lines mean? I am new to buildozer, so I'm not quite sure what to do here. Thanks in advance for your help.
By default, buildozer looks for a line in your main.py of the form __version__ = 'something'. This is used to set the apk version, a required field.
You can either add this line to your main.py, or comment out the version check and uncomment the alternative version method on the next lines of buildozer.spec. This lets you set the version string in buildozer.spec itself.
Add version = '0.1' at the top of your main.py file so you can package your application without any error.
I 'm not able to install python packages from both pip and easy_install. There's some absurd kind of error that keeps popping up. Kindly help to rectify it.
I get the same errors while using python setup.py install.
Error while installing django-memcached
C:\Users\Praful\Desktop\django-redis-master>easy_install django-memcached
Traceback (most recent call last):
File "C:\Python27\Scripts\easy_install-script.py", line 9, in <module>
load_entry_point('distribute==0.6.27', 'console_scripts', 'easy_install')()
File "C:\Python27\lib\site-packages\distribute-0.6.27-py2.7.egg\setuptools\com
mand\easy_install.py", line 1915, in main
with_ei_usage(lambda:
File "C:\Python27\lib\site-packages\distribute-0.6.27-py2.7.egg\setuptools\com
mand\easy_install.py", line 1896, in with_ei_usage
return f()
File "C:\Python27\lib\site-packages\distribute-0.6.27-py2.7.egg\setuptools\com
mand\easy_install.py", line 1919, in <lambda>
distclass=DistributionWithoutHelpCommands, **kw
File "C:\Python27\lib\distutils\core.py", line 112, in setup
_setup_distribution = dist = klass(attrs)
File "C:\Python27\lib\site-packages\distribute-0.6.27-py2.7.egg\setuptools\dis
t.py", line 222, in __init__
for ep in pkg_resources.iter_entry_points('distutils.setup_keywords'):
File "C:\Python27\lib\site-packages\distribute-0.6.27-py2.7.egg\pkg_resources.
py", line 486, in iter_entry_points
entries = dist.get_entry_map(group)
File "C:\Python27\lib\site-packages\distribute-0.6.27-py2.7.egg\pkg_resources.
py", line 2315, in get_entry_map
self._get_metadata('entry_points.txt'), self
File "C:\Python27\lib\site-packages\distribute-0.6.27-py2.7.egg\pkg_resources.
py", line 2101, in parse_map
raise ValueError("Entry points must be listed in groups")
ValueError: Entry points must be listed in groups
Error while installing python-memcache
C:\Users\Praful\Desktop\mem>python setup.py install
Traceback (most recent call last):
File "setup.py", line 24, in <module>
"Topic :: Software Development :: Libraries :: Python Modules",
File "C:\Python27\lib\distutils\core.py", line 112, in setup
_setup_distribution = dist = klass(attrs)
File "C:\Python27\lib\site-packages\distribute-0.6.27-py2.7.egg\setuptools\dis
t.py", line 222, in __init__
for ep in pkg_resources.iter_entry_points('distutils.setup_keywords'):
File "C:\Python27\lib\site-packages\distribute-0.6.27-py2.7.egg\pkg_resources.
py", line 486, in iter_entry_points
entries = dist.get_entry_map(group)
File "C:\Python27\lib\site-packages\distribute-0.6.27-py2.7.egg\pkg_resources.
py", line 2315, in get_entry_map
self._get_metadata('entry_points.txt'), self
File "C:\Python27\lib\site-packages\distribute-0.6.27-py2.7.egg\pkg_resources.
py", line 2101, in parse_map
raise ValueError("Entry points must be listed in groups")
ValueError: Entry points must be listed in groups
Find get_entry_map(self, group=None): into python\Lib\sitepackages\pkg_resources\__init__.py. Insert after print self.egg_info
Run python setup.py and look to the last printed - broken package.
Remember it, later to install again. Delete the folder of broken
package and folder broken_package-version.dist-info. Run again paragraph 2, until the error disappears.
Remove changes from paragraph 1.
python setup.py install 'broken_package'
This error happened to me installing any package. My solution was going to my file explorer, typing in the path bar %appdata%, going to the Python folder, and deleting everything inside.
I found the same problem to be caused by a misfometted entry_points.txt file in one instelled egg of mine.
It can be quite hard to track down which one is if there are many.
I managed to find that little ba##!"d by creating and run setup.py for a dummy package:
setup.py
from setuptools import setup, find_packages
setup(
name = "IWillFindYou",
version = "0.1",
packages = find_packages()
)
run this in debug mode would point to this line in pkg_resources.py
def parse_map(cls, data, dist=None):
[...]
raise ValueError("Entry points must be listed in groups")
if you go back to the stack trace, you will see that parse_map is called here:
def get_entry_map(self, group=None):
[...]
ep_map = self._ep_map = EntryPoint.parse_map(
self._get_metadata('entry_points.txt'), self
)
evaluating self.egg_info will point up your evil egg so you can give a look to the entry_points.txt file.
If you are not handy with debugger, you may try to place print self.egg_info in get_entry_map and look to the last guy printed.
My Resolution Approach
Platform: windows 10, ConEmu-Maximus5
Delete virtual environment automatically created by poetry install command.
windows users can find the virtual environment folder in the path below
C:\Users\YOUR_PC_USERNAME\AppData\Local\pypoetry\Cache\virtualenvs
(don't know of linux path)
close terminal / command prompt
open terminal / command prompt and navigate to project folder
re run poetry install
I hope it helps...
How i encountered the error
It was my first time using poetry, while running poetry install, the process got interrupted. running the command again popped out the error.
Could be a problem with distribute. I'd recommend re-installing Python.