How to Solve MagicException: "could not find any magic files" in s3cmd? - python

I am using s3cmd to upload files.
and it always upload .png file as "image/x-png" for MIME type.
So I decide to install "python-magic"
What I did here:
Installed Python 2.7 x86 on Windows 7 64bit, (since the manual of "python-magic" said only x86 will work) download from http://www.python.org/download/releases/2.7/
Installed Python Extention Setuptools http://www.lfd.uci.edu/~gohlke/pythonlibs/#setuptools
Download & Installed https://github.com/ahupp/python-magic , use 'C:\Python27\python setup.py install'
Found the 3 files ( magic1.dll, zlib1.dll, regex2.dll, as required by python-magic ) and copied to Windows/System32
ok, at last s3cmd is using python-magic for MIME, BUT errors:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
An unexpected error has occurred.
Please report the following lines to:
s3tools-bugs#lists.sourceforge.net
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Problem: MagicException: could not find any magic files!
S3cmd: 1.1.0-beta3
Traceback (most recent call last):
File "T:\My\Downloads\s3cmd\s3cmd", line 1788, in <module>
from S3.S3 import S3
File "T:\My\Downloads\s3cmd\S3\S3.py", line 35, in <module>
magic_ = magic.Magic(mime=True)
File "build\bdist.win32\egg\magic.py", line 51, in __init__
magic_load(self.cookie, magic_file)
File "build\bdist.win32\egg\magic.py", line 138, in errorcheck
raise MagicException(err)
Please advice how or where can I get some magic files.

Related

Installing Gumbo and its Python wrapper

I am trying to use Gumbo's python wrapper to parse HTML.
My operating system is Ubuntu 14.04.3 LTS. I am using Python2.7
I have cloned the latest version of Gumbo from github.
I followed the installation steps provided on Github.
The installation of the libraries, both the C library and the python wrapper, appeared to be successful ( No error message, both printed successful messages at the end )
C library final message:
Libraries have been installed in: /usr/local/lib
Python wrapper message:
Installed
/usr/local/lib/python2.7/dist-packages/gumbo-0.10.1-py2.7.egg
Processing dependencies for gumbo==0.10.1 Finished processing
dependencies for gumbo==0.10.1
The first problem I encountered was when I tried to open pydoc for gumbo, to better understand the library.
pydoc gumbo produced the following error:
problem in gumbo - <type 'exceptions.OSError'>: /usr/local/lib/python2.7/dist-packages/gumbo-0.10.1-py2.7.egg/gumbo/libgumbo.so: cannot open shared object file: No such file or directory
Searching for the message yielded a single result.
It was not of much use to me.
Looking at the dist-packages directory, I noticed that libgumbo.so was not in /usr/local/lib/python2.7/dist-packages/gumbo-0.10.1-py2.7.egg/gumbo/ . All other files ( soup-adapter.py, gumboc.py, etc ) where there however.
The installation of the C library placed libgumbo.so ( and some other libraries, like libgumbo.a libgumbo.la, etc ) in /usr/local/lib. So, as a work around, I created a simlink from .../dist-packages/gumbo-0.10.1-py2.7.egg/gumbo/ to /usr/local/lib.
This got pydoc gumbo to work.
I tried to import gumbo and soup-adapter in the interpreter after. I received the following error:
import soup_adapter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "soup_adapter.py", line 26, in <module>
import gumboc
File "gumboc.py", line 44, in <module>
os.path.dirname(__file__), _name_of_lib))
File "/usr/lib/python2.7/ctypes/__init__.py", line 443, in LoadLibrary
return self._dlltype(name)
File "/usr/lib/python2.7/ctypes/__init__.py", line 365, in __init__
self._handle = _dlopen(self._name, mode)
OSError: libgumbo.so: cannot open shared object file: No such file or directory
I am not sure how to proceed or how exactly to get gumbo to work.

PIL with Centos 7 and Python 3.4

Does anyone have a working implementation of PIL with Centos 7 and Python 3.4?
I tried to install the tarball from here, but when running "make" or "make test" got a lot of errors.
If anyone has a working implementation, could you please post the commands and configuration needed i.e. yum packages to get it to work?
I also found this blog post but it didn't help.
Here is one error that I am seeing when trying to convert a jpeg's size:
Traceback (most recent call last):
File "<console>", line 2, in <module>
File "/var/www/deploy/myproject/myproject-django/venv/lib/python3.4/site-packages/PIL/Image.py", line 1557, in resize
self.load()
File "/var/www/deploy/myproject/myproject-django/venv/lib/python3.4/site-packages/PIL/ImageFile.py", line 203, in load
d = Image._getdecoder(self.mode, d, a, self.decoderconfig)
File "/var/www/deploy/myproject/myproject-django/venv/lib/python3.4/site-packages/PIL/Image.py", line 420, in _getdecoder
raise IOError("decoder %s not available" % decoder_name)
OSError: decoder jpeg not available
Make sure you install the dependencies first, and then reinstall Pillow. Looks like you're missing libjpeg. See here for details.
http://pillow.readthedocs.org/en/3.0.x/installation.html

Py2app with native Python 2.6

I have a python application primarily dependent on matplotlib, tkinter, numpy and scipy I have been distributing for multiple operating systems. I build these on top of the python.org version of python 2.6. For mac, I have had good success in the past with py2app and pyinstaller to build standalone versions of my application. Recently, however, I have included functions that require patsy, pandas and igraph and have had to move to the mac distributed version of python 2.6 in order to get igraph to work. All works fine in building a py2app version of my software on the Mac for my OS (10.6) but when I run on 10.8 I encountered the following error:
Traceback (most recent call last):
File "UI.pyc", line 603 createHeatMap
File "clustering.pyc", line 31, in <module>
File "mpl_toolkits/__init__.pyc", line 2, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 698, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 701, in Environment
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 96, in get_supported_platform
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 222, in get_build_platform
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/util.py", line 98, in get_platform
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/sysconfig.py", line 537, in get_config_vars
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/sysconfig.py", line 405, in _init_posix
DistutilsPlatformError: invalid Python installation: unable to open /user/include/python2.6/pyconfig.h (No such file or directory)
This is fixed by saving the file pyconfig.h to the designated location on the destination machine (not present in 10.8 but present in 10.6), which allows my application to work fine. In my py2app pacakge directory, under "Contents/Resources" there is a sym-link to the directory "include" which points to: /System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/pyconfig.h. If I include the pyconfig.h file as an addition resource in my py2app setup file, it also includes it in the package, but it still is not recognized.
Can anyone suggest a good work around for this that doesn't require me to use the python.org version of python (I've had horrible luck getting igraph to work with this).
Thanks...
This is a known issue in py2app, see https://bitbucket.org/ronaldoussoren/py2app/issue/36/py2app-fails-to-build-a-working-executable. The pyconfig.h file is only present on machines where the developer tools are installed, which is why I haven't noticed the problem myself.
The easiest workaround is probably to replace the pyconfig.h symlink by a copy of the file after creating the app bundle.

Ipython installation on 3.3 x64 errors

I don't have experience in downloading libraries, so any help is appreciated. I've got a fresh install of Python3.3 and am trying to get IPython for 64bit Windows 7. The IPython .exe installer ran fine and completed normally, but I can't access the program. I looked through their documentation, and tried the commands there, but
$ python setup.py install
returns invalid syntax, highlighting "setup". I thought the fix might be in the distribute library mentioned on the page, so I went to go try and get that first. However, using the script from distribute's install page revealed it's own errors, namely
Traceback (most recent call last):
File "C:\Python33\distribute_setup.py", line 541, in <module>
sys.exit(main())
File "C:\Python33\distribute_setup.py", line 537, in main
tarball = download_setuptools(download_base=options.download_base)
File "C:\Python33\distribute_setup.py", line 200, in download_setuptools
log.warn("Downloading %s", url)
File "C:\Python33\lib\distutils\log.py", line 47, in warn
self._log(WARN, msg, args)
File "C:\Python33\lib\distutils\log.py", line 30, in _log
if stream.errors == 'strict':
AttributeError: errors
I've been at it for a couple hours now, and I'm fresh out of ideas. What next?
It looks like you ran into Python bug 12967. You need to run distribute_setup.py outside of IDLE (i.e. in a command prompt).

"AttributeError: fileno" when attemping to import from pyevolve

I just installed Pyevolve using easy_install and I am getting errors trying to run my first program. I first tried copy and pasting the source code of the first example but this is what I receive when I attempt to run it:
Traceback (most recent call last):
File "/home/corey/CTest/first_intro.py", line 3, in
from pyevolve import G1DList
File "/usr/lib/python2.6/site-packages/Pyevolve-0.5-py2.6.egg/pyevolve/init.py", line 15, in
File "/usr/lib/python2.6/site-packages/Pyevolve-0.5-py2.6.egg/pyevolve/Consts.py", line 240, in
import Selectors
File "/usr/lib/python2.6/site-packages/Pyevolve-0.5-py2.6.egg/pyevolve/Selectors.py", line 12, in
File "/usr/lib/python2.6/site-packages/Pyevolve-0.5-py2.6.egg/pyevolve/GPopulation.py", line 11, in
File "/usr/lib/python2.6/site-packages/Pyevolve-0.5-py2.6.egg/pyevolve/FunctionSlot.py", line 14, in
File "/usr/lib/python2.6/site-packages/Pyevolve-0.5-py2.6.egg/pyevolve/Util.py", line 20, in
AttributeError: fileno
I am running python 2.6 on Fedora 11 X86_64.
Edit: After looking into it more if I run python from the command line it works but it only fails when I'm running IDLE.
Have you tried to check out the Development version ? It's near of the RC1, so it is stable right now:
svn co https://pyevolve.svn.sourceforge.net/svnroot/pyevolve/trunk pyevolve
Your problem seems to be the paths, try uncompressing the "egg" file and put the "pyevolve" directory in the site-packages or inside your application directory.

Categories