IOError: No suitable library found for xls - python-2.7

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

Related

ImportError: cannot import name _remove_dead_weakref python 2.7

I use windows 7 and python 2.7
When I used py2exe to make an .exe file I get the error;
Traceback (most recent call last):
File "mainpy", line 17, in
File "main.py", line 17, in
File "zipextimporter.pyc", line 82, in load_module
File "zipextimporter.pyc", line 82, in load_module
File "logging_init_.pyc", line 26, in
File "zipextimporter.pyc", line 82, in load_module
File "weakref.pyc", line 14, in
ImportError: cannot import name _remove_dead_weakref
The same code could be used to make an .exe file in another computer so there is nothing wrong with the code in main.py. The minor environmental difference may cause this problem. I used pycharm, python 2.7.10 and py2exe 0.6.9. On another computer all other config are the same except using sublimetext instead of pycharm.
Could anyone please tell me how to fix that?
Another tricky thing is that
It is possible that the library does not exists for the other computer.Please check whether the library exists or not.

Bottle micro framework suddenly crash

i have web app that i have developed using bottle micro framework.
However it crash a lot and all of them suddenly without any action ( without using the web app) . So i have reviewed the logs file and find the following errors (i have no idea what the causation of these errors):
Traceback (most recent call last):
File "/home/hamoud/lib/python2.7/bottle.py", line 2699, in run
server.run(app)
File "/home/hamoud/lib/python2.7/bottle.py", line 2385, in run
srv = make_server(self.host, self.port, handler, **self.options)
File "/usr/local/lib/python2.7/wsgiref/simple_server.py", line 144, in make_server
server = server_class((host, port), handler_class)
File "/usr/local/lib/python2.7/SocketServer.py", line 419, in __init__
self.server_bind()
File "/usr/local/lib/python2.7/wsgiref/simple_server.py", line 48, in server_bind
HTTPServer.server_bind(self)
File "/usr/local/lib/python2.7/BaseHTTPServer.py", line 108, in server_bind
SocketServer.TCPServer.server_bind(self)
File "/usr/local/lib/python2.7/SocketServer.py", line 430, in server_bind
self.socket.bind(self.server_address)
File "/usr/local/lib/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
TypeError: 'int' object is not callable
and
Traceback (most recent call last):
File "interface.py", line 29, in <module>
run(host="localhost", port=32471, reloader=True, debug=True)
File "/home/hamoud/lib/python2.7/bottle.py", line 2657, in run
os.utime(lockfile, None) # I am alive!
OSError: [Errno 2] No such file or directory: '/tmp/bottle.gQmJc8.lock'
However the second error doesn't crash the application ( application would continue working ) but for the first one it's require manual work ( run the app again ).
i could schedule task using cron job to run the application when it's crash. but i'd like to know what's the problem in my app.
A few ideas come to mind:
Could there be another program on your machine (e.g., a cron job) that is deleting files from /tmp?
Are you using the latest version of Bottle? (From the line number in your stacktrace, it looks like you might not be.)
If nothing else works, try running without reloader=True (or use reloader=False). I looked at the Bottle code, and that change should at least work around the problem, even though we don't know the cause (yet).
Hope that helps.

epub library for python

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...

trigger.io error building "No module named generate_dynamic"

I seem to have a strange error when trying to build my app
Couldn't import generation code: No module named generate_dynamic
What is strange about this error is that I can seem to resolve the error if I uninstall and re-install trigger.io but if I make any changes tot he config the error comes back and I have to uninstall and re-install each time I make a change to the configs. It never used to do this.
Traceback (most recent call last):
File "C:\Users\Michael\AppData\Local\Trigger Toolkit\build-tools\forge\async.py", line 106, in run
result = self._target(*self._args, **self._kwargs)
File "C:\Users\Michael\AppData\Local\Trigger Toolkit\trigger\api\app.py", line 290, in package
build(cookies, path, target)
File "C:\Users\Michael\AppData\Local\Trigger Toolkit\trigger\api\app.py", line 329, in build
forge_main.development_build([target, '--general.interactive', 'no'])
File "C:\Users\Michael\AppData\Local\Trigger Toolkit\build-tools\forge\main.py", line 335, in development_build
manager.fetch_instructions()
File "C:\Users\Michael\AppData\Local\Trigger Toolkit\build-tools\forge\templates.py", line 90, in fetch_instructions
import_generate_dynamic(do_reload=True)
File "C:\Users\Michael\AppData\Local\Trigger Toolkit\build-tools\forge\build.py", line 48, in import_generate_dynamic
raise ForgeError("Couldn't import generation code: {0}".format(e))
ForgeError: Couldn't import generation code: No module named generate_dynamic
That is the debug. Note sure what is going on.
Thanks.
So it looks like its not resolved, I tried to update a module and the whole thing blew up again. I sent the logs to support so we will see how long this will take.
* Edit *
I was able to resolve this by deleting the trigger.Io directory ( the uninstall does not do this ) then reinstalling and importing my project again. Not sure what happened but it's working now
I deleted the .tempalte folder and re-built. Looks like the content of that folder got jacked during a failed or canceled build.

Running django on GAE + Cloud SQL, with third party reusable django apps ( like South)

I'm planing to run a django project on google cloud plateform (GAE, Cloud SQL). The project uses several django reusable apps (libraries) like South, django-debug-toolbar, django-compressor, etc. So, i'm wondering if there is a way to manage all these libraries on appengine? if Yes, how.
PS: I've tried to define dependencies in the app.yaml file, but i'm getting errors:
Traceback (most recent call last):
File "/usr/local/bin/dev_appserver.py", line 197, in <module>
_run_file(__file__, globals())
File "/usr/local/bin/dev_appserver.py", line 193, in _run_file
execfile(script_path, globals_)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 855, in <module>
main()
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 848, in main
dev_server.start(options)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 657, in start
options.yaml_files)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/application_configuration.py", line 556, in __init__
module_configuration = ModuleConfiguration(yaml_path)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/application_configuration.py", line 82, in __init__
self._yaml_path)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/application_configuration.py", line 272, in _parse_configuration
return appinfo_includes.ParseAndReturnIncludePaths(f)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/appinfo_includes.py", line 63, in ParseAndReturnIncludePaths
appyaml = appinfo.LoadSingleAppInfo(appinfo_file)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/appinfo.py", line 1743, in LoadSingleAppInfo
listener.Parse(app_info)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/yaml_listener.py", line 226, in Parse
self._HandleEvents(self._GenerateEventParameters(stream, loader_class))
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/yaml_listener.py", line 177, in _HandleEvents
raise yaml_errors.EventError(e, event_object)
google.appengine.api.yaml_errors.EventError: the library "django-appconf" is not supported
in "jobbr/app.yaml", line 13, column 1
Sorry, but at least South and django-compressor would not run on GAE.
GAE is a completely different platform. Yet you have SQL access to your tables, it's just an abstraction layer over a nonrelative database. There is no filesystem access, but there are tons of other limitations. Even Django itself could not be run on GAE without patches - you have to use special version, django-nonrel.
I would suggest to read more GAE documentation so you can decide if a particular application could be run there or not.