zipimport.ZipImportError: can't decompress data; zlib not available - python

I would like to use cx_freeze to change my hello_world.py into exe file.
When I run cxfreeze like this:
cxfreeze hello_world.py
And I run the exe file, it comes the error:
./hello_world
Fatal Python error: Py_Initialize: Unable to get the locale encoding
Traceback (most recent call last):
File "/home/karl/anaconda3/lib/python3.6/encodings/__init__.py", line 31, in <module>
zipimport.ZipImportError: can't decompress data; zlib not available
Aborted (core dumped)
Does anyone know how to solve this?

Run the below code which will install zlib:
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
Thanks to the answer at https://stackoverflow.com/a/52756409/9162193

On MacOS the issue is often that an XCode update has removed zlib. The solution in these cases would be running:
xcode-select --install
On Linux machines you would need to install zlib, see for instance this answer.

Related

opencv import failed in windows container (on Windows Server 2016)

I run the following container to test my opencv-python environment on Windows Server 2016.
docker run -i --rm python:2.7-windowsservercore
(the python:2.7-windowsservercore image is an official python image which is base on microsoft/windowsservercore)
and in the interacive console, I got the opencv-python installed by:
pip install opencv-python
after this finished, I test the opencv-python package by:
python -c "import cv2"
but I got the following error:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Python\lib\site-packages\cv2\__init__.py", line 9, in <module>
from .cv2 import *
ImportError: DLL load failed: The specified module could not be found.
then I installed python-2.7.13 on the host(not inside container), input the same pip install commands, and test python -c "import cv2" again, it won't report any error. I wonder if there are some DLL files are missing in the container? What package or software should I install in the container to fix this error?
Based on the accepted answer to this question I would put my money on you not having the required MSVC runtime. Assuming it was compiled with Visual Studio 2015 the runtime can be downloaded from Visual C++ Redistributable for Visual Studio 2015
I found the solution in this place.
Copy the following files from your host into your container's \System32 folder:
msacm32.dll
avifil32.dll
avicap32.dll
msvfw32.dll

IPTCInfo on Python 3.x Windows

I need to extract IPTC metadata from images. Most of the things I've read about Python packages on Windows suggest using pre-compiled binaries, but I don't see one for IPTCInfo, thus I tried pip3.
I'm getting an error from pip when trying to install this:
C:\Users\hackr>pip3 install IPTCInfo
Collecting IPTCInfo
Downloading IPTCInfo-1.9.5-6.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\hackr\AppData\Local\Temp\pip-build-v4m344a7\IPTCInfo\setup.py", line 32
print self.get_archive_files()
^
SyntaxError: invalid syntax
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\hackr\AppData\Local\Temp\pip-build-v4m344a7\IPTCInfo
So, I tried to open that last temporary file it refrences, but it doesn't appear to exist...
I have the same problem. Appears the IPTCinfo is for python-2. I will upgrade IPTCinfo for python-3.
However I have found the library exvi2 which provides the same type of image support. There is a python interface for this at https://wiki.gnome.org/Projects/gexiv2
I maintain IPTCInfo3 in Pypi. I recommend downloading it via pip3 install iptcinfo3 as it is specifically upgraded for Python3x. Follow the readme and issue comments for examples. Enjoy.

gtimelog can't find pygtk installed via Homebrew on Mac OS

I have installed Python via Homebrew. I also installed pygtk via Homebrew
I went to install gtimelog via pip but it tells me it's already installed, it appears to have come down with Python in Homebrew
When I attempt to run gtimelog I get ImportError: No module named pygtk
It appears to be a $PYTHONPATH issue but I can't seem to resolve it.
I run into the same issue. Read the Homebrew log:
==> Installing pygtk
==> Downloading http://ftp.acc.umu.se/pub/GNOME/sources/pygtk/2.24/pygtk-2.24.0.tar.bz2
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/pygtk/2.24.0
==> make install
==> Caveats
For non-Homebrew Python, you need to amend your PYTHONPATH like so:
export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH
==> Summary
The problem is that even with the right PYTHONPATH I'm getting an error when running gtimelog:
$ gtimelog
Traceback (most recent call last):
File "/usr/local/bin/gtimelog", line 8, in <module>
load_entry_point('gtimelog==0.8.0dev', 'gui_scripts', 'gtimelog')()
File "/Library/Python/2.7/site-packages/gtimelog-0.8.0dev-py2.7.egg/gtimelog/main.py", line 2208, in main
tray_icon = icon_class(main_window)
File "/Library/Python/2.7/site-packages/gtimelog-0.8.0dev-py2.7.egg/gtimelog/main.py", line 1148, in __init__
'style-updated', self.on_style_set) # Gtk+ 3
TypeError: <gtk.Window object at 0x10b443cd0 (GtkWindow at 0x7fe09aacd1d0)>: unknown signal name: style-updated
**Update:
For Mountain Lion you need to install XQuarks as apple doesn't ship X11 with their OS anymore..
As per why gtimelog wasn't opening, It is a gtimelog bug and if you edit ~/.gtimelog/gtimelogrc and set show_tray_icon to False you will get it working!

Installing SSL Module for Python (2.5.4) on Windows

since AppEngine requires to upload your apps via SSL I tried to install the module on my working laptop.
It is a x64 Win 7 System with Python 2.5.4 x86 installed.
I followed guides such as this one: How to install Python ssl module on Windows?
and also all related links.
But the major problem is, that neither MinGw nor GnuWin seems to really work.
GnuWin is perfectly installed, up to date and has all dependencies it needs to build the SSL module.
But typing in
> "C:\Python25\python.py" setup.py install -c mingw32
just badly fails.
So does "-cmingw32" and "-gnuwin32".
(-cmingw32 obviously fails, because even though MinGW is fully installed MinGw is not regcognized)
"build" instead of install seems to "output" something:
MinGw complains about "ggc no such file or directory", and with GnuWin "it doesn't know how to compile C/C++ on a nt with gnuwin"
This sounds like total garbage to me, because I did everything as described in the tutorials.
I fixed one part of my problem: gcc is now getting recognized by easy_install but AE still complains about the missing SSL module though both, easy_install and python say Pycrypto incl. SSL is successfully installed
easy_install ssl
C:\Users\faits>easy_install ssl
Searching for ssl
Best match: ssl 1.15
Adding ssl 1.15 to easy-install.pth file
Using c:\python25\lib\site-packages
Processing dependencies for ssl
Finished processing dependencies for ssl
easy_install pycrypto
C:\Users\faits>easy_install ssl
Searching for ssl
Best match: ssl 1.15
Adding ssl 1.15 to easy-install.pth file
Using c:\python25\lib\site-packages
Processing dependencies for ssl
Finished processing dependencies for ssl
python
IDLE 1.2.4
>>> import ssl
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import ssl
File "C:\Python25\lib\site-packages\ssl\__init__.py", line 61, in <module>
import _ssl2 # if we can't import it, let the error propagate
ImportError: No module named _ssl2
python
>>> import pycrypto
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import pycrypto
ImportError: No module named pycrypto
I've summed up all the instructions nicely on the following link. Do check it out.
http://waqasshabbir.tumblr.com/post/18010535789/ssl-module-for-python-2-5-installation-windows-only
Use -c with the build command.
Compare:
$ python setup.py install -c
--compile (-c) compile .py to .pyc [default]
with:
$ python setup.py build -c
--compiler (-c) specify the compiler type
To find out other options , run:
$ python setup.py build --help

Problems installing MySQL-python-1.2.3c1 on Mac Snow Leopard

I am having a problem installing the Python MySQL connector (MySQL-python-1.2.3c1) on my Mac OSX Snow Leopard.
System State
I have manually compiled an installed:
mysql-5.1.41
This seems to work fine, as I can create and query a database from the commandline.
I have compiled:
MySQL-python-1.2.3c1
I first set the following in the site.cfg file:
mysql_config = /usr/local/mysql/bin/mysql_config
I then built and compiled MySQL-python-1.2.3c1 following their guide:
sudo python setup.py build
sudo python setup.py install
I now test the installation with Python:
python -c "import MySQLdb"
Error Message
This then gives me the following error, and I'm stumped as to how to fix it:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "build/bdist.macosx-10.6-universal/egg/MySQLdb/__init__.py", line 19, in <module>
File "build/bdist.macosx-10.6-universal/egg/_mysql.py", line 7, in <module>
File "build/bdist.macosx-10.6-universal/egg/_mysql.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/username/.python-eggs/MySQL_python-1.2.3c1-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so, 2): Symbol not found: _mysql_affected_rows
Referenced from: /Users/username/.python-eggs/MySQL_python-1.2.3c1-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so
Expected in: flat namespace
in /Users/username/.python-eggs/MySQL_python-1.2.3c1-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so
mymac: username$
Things I've Tried
I've looked at this blog antoniocangiano.com but it is for an older version of MySQL-python and is not really applicable. But I tried adding the soft link it mentions.
I then looked at this blog post: http://blog.some-abstract-type.com/2009/09/mysql-python-and-mac-os-x-106-snow.html. And tried building compiling with the ARCHFLAGS settings - but no joy.
Please Help
If you have any ideas please let me know.
Many thanks
Ben...
First, I would suggest using the MySQL binaries for MacOS X 10.5 64-bit (x86_64). The tar ball works on MacOS X 10.6.
You said you used ARCHFLAGS.. however, try it again like this:
shell> ARCHFLAGS="-arch x86_64" python setup.py build
shell> sudo python setup.py install
Thus building as normal user, installing as root. (It's good to remove the source, and unpack correcting the site.cfg file again).
What does
otool -L /Users/username/.python-eggs/MySQL_python-1.2.3c1-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so
report?

Categories