Python py2app and pillow error: Mach-O header is too large - python

I'm unable to use py2app to build a python application which contains the pillow package. I'm using:
Mac OSX El Capitan (10.11.16)
Python 3.7.3 (Installed via Homebrew)
Pillow 6.0.0
py2app 0.19
macholib 1.11
The script works fine when called from the command line and the py2app bundle works fine if compiled in alias mode python3 setup.py py2app -A
But, when I try to compile a standalone bundle using:
python3 setup.py py2app --packages=PIL
I get the following error message:
ValueError: New Mach-O header is too large to relocate in '/Users/RG/Library/Mobile Documents/com~apple~CloudDocs/iHal/Code/QuotesApp/dist/Quotes.app/Contents/Resources/lib/python3.7/PIL/.dylibs/liblcms2.2.dylib' (new size=1688, max size=1680, delta=48)
I've been searching but have had no luck finding help with this issue, is it possible it's an El Capitan (OSX 10.11.16) issue?

my system specs:
Mac OSX Mojave (10.14.15)
Python 3.7.4 (python.org)
Pillow 6.1.0
py2app 0.19
macholib 1.11
I had the same issues as you. The reason why it fails is that the library is wrong compiled. I figured out two solutions.
On my system the library is located at: /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/PIL/.dylibs/
If you do not use color management in your project you can delete the library "liblcms2.2.dylib". Now you can run py2app and it will build.
The second solution is more work and the way I use it in my project.
First, you need Xcode because we have to recompile the "littlecms" library.
Xcode is around 6gb and you get it from the Apple Appstore. On my system have the version 10.2.1.
Download the library littlecms in version 2.2: https://www.littlecms.com/
You will be redirected to SourceForge:
https://sourceforge.net/projects/lcms/files/lcms/2.2/
Download one of these files: lcms2-2.2.zip or lcms2-2.2.tar.gz and extract it on your system.
The library source comes with the Xcode project file and you will find in Projects/mac.
If you are familiar with the terminal you can build it without the Xcode GUI. In this case, go into the extracted folder of littlecms and type following commands.
./configure
make
make check
If the last command(make check) runs fine the library is ready for deployment.
You will find the compiled library in the folder: src/.libs/.
Replace the library which comes with the PIL package with your compiled library.
Finally, run py2app to build your project.
If this is not working you have to tell the linker a flag.
Go to your littlecms source folder and type the commands:
make clean
./configure LDFLAGS="-headerpad_max_install_names"
make
make check
Replace the compiled library with the PIL.
so long,
Phil

Related

Can PyInstaller from native Python include low-level dependencies like it does when using from Conda?

We need to deploy Python 3 script on RHEL 7.9 that has Python 2.7.5 and GLIBC 2.27. Don't have sudo privileges there, so we need to somehow bundle the whole project with all dependencies.
PyInstaller works perfectly, but only when used from Conda environment. On native Python it produces much smaller package and bin execution returns error:
[3989] Error loading Python lib '/path/libpython3.8.so.1.0': dlopen: /lib64/libm.so.6: version `GLIBC_2.29' not found (required by /path/libpython3.8.so.1.0)
Conda build has 202 elements in build dir:
While build with regular Python only 31:
Is there a way to build the project with all low-level dependencies like with Conda but using some free license tool?

Why is this PySide2 build failing to find a generated C++ wrapper?

I'm trying to build the latest release of PySide2 on MacOs Sierra 10.12.2 (16C67) with python 3.6. As of now, the build invoked with
python3 setup.py build
is failing with the following error: (I have substituted my name out of my home directory...)
clang: error: no such file or directory: '/Users/myusername/pythonpackage/pyside-setup/pyside3_build/py3.6-qt5.8.0-64bit-release/pyside2/PySide2/QtCore/PySide2/QtCore/qabstractstate_wrapper.cpp'
I am using Qt 5.8 as installed by homebrew.
I have looked through the build log and cannot find where/if that file is generated, as I am not familiar with the binding generation. Using PyQt is not an option, as its license is not applicable to my application.
Why is this source missing, and what can I do to make the build succeed?
PySide2 was installed from this repo: git://code.qt.io/pyside/pyside-setup.git
Turns out I stated the issue in the actual question: The PySide2 README states that it supports Qt 5.5 and 5.6. I was trying to use 5.8.
I solved my problem by using an old homebrew qt installed via:
curl -O https://raw.githubusercontent.com/Homebrew/homebrew-core/fdfc724dd532345f5c6cdf47dc43e99654e6a5fd/Formula/qt5.rb
brew install ./qt5.rb
followed by the build invocation, and it worked.

Installing VMD with python support on MAC

I have been trying to install VMD1.9.2 on a Macbook with python support but have not been able to. It seems to me that the packaged .dmg file for VMD comes without Python support. I have used the command vmdinfo options to find the options my VMD is installed with and MACOSXX86 FLTKOPENGL FLTK TK ACTC CUDA IMD LIBSBALL LIBTACHYON VRPN NETCDF TCL PTHREADS SILENT this is the result which shows that it does not have Python support. My question- Is there an easy way to add python support rather than compiling from source? I just drag the App after unpacking the .dmg file to Applications folder. Am I doing something wrong while installing it this way? Is there any other way at all?
`
Robin Betz has created the vmd-python package. You can install it with conda:
conda install -c conda-forge vmd-python
More informations can be found in the package documentation.

How to install aggdraw with Python 2.7

I'd like to use aggdraw with Python 2.7. (Is this a dumb idea anyway? I've seen a nice aggdraw example, but I don't want to regress to Python 2.6. Is there an equivalent drawing library working with Python 2.7?) I have Python 2.7.8 64bit installed on a Windows 7 Enterprise SP 1 64bit.
The installer at http://www.effbot.org/downloads#aggdraw complains about Python 2.6 missing, and python setup.py install complains about a missing vcvarsall.bat.
So, following all the related posts here, I installed the MS compiler from http://www.microsoft.com/en-us/download/details.aspx?id=44266. It's visible in the "Programs and Features" list, and I have a vcvarsall.bat in C:\Users\d031475\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0 now.
Still, python setup.py install neither runs in CMD directly, nor in the MS Visual... Compiler for Python 2.7 command prompt which appeared in my Start menu. It still complains about a missing vcvarsall.bat.
EDIT: Even when I append the relevant directory to my path, so that I can run vcvarsall.bat from the command line, python setup.py install still complains it can't find it. How strange is that?
To build with "Microsoft Visual C++ Compiler for Python 2.7" you need to use setuptools >= 6.0 instead of distutils. Try to change the line from distutils.core import setup, Extension in setup.py to from setuptools import setup, Extension.
You'll need to build against the freetype library to enable text rendering.
The aggdraw project appears to be abandoned. The latest version 1.2a3 is from early 2006 and predates Python 2.7, 64 bit, and Pillow. Expect crashes, especially on 64 bit for Windows.
Unofficial Windows binaries for aggdraw are available at http://www.lfd.uci.edu/~gohlke/pythonlibs/#misc.
An alternative to aggdraw is pycairo (Windows binaries).
Do not try to mess around with the Compiler things yourself.
The by far easiest and tested solution is to download the to your environment fitting Windows Binaries for aggdraw from here:
http://www.lfd.uci.edu/~gohlke/pythonlibs/
Once you have it go in cmd to your download folder and install with pip (use filename of just downloaded whl script.
pip install aggdraw-1.2a3-cp27-none-win32.whl
DONE!

Installing PIL (Python Imaging Library) in Win7 64 bits, Python 2.6.4

I'm trying to install said library for use with Python. I tried downloading the executable installer for Windows, which runs, but says it doesn't find a Python installation. Then tried registering (http://effbot.org/zone/python-register.htm) Python, but the script says it can't register (although the keys appear in my register).
Then I tried downloading the source package: I run the setup.py build and it works, but when I run setup.py install it says the following:
running install
running build
running build_py
running build_ext
building '_imaging' extension
error: Unable to find vcvarsall.bat
What can I do?
UPDATE (May 2014): Like said by some comments and answers, PIL is currently unmantained, and the way to go now is to use Pillow (https://pypi.python.org/pypi/Pillow/, pip install pillow).
I found a working win7 binary here: Unofficial Windows Binaries for Python Extension Packages It's from Christoph Gohlke at UC Irvine. There are binaries for python 2.5, 2.6, 2.7 , 3.1 and 3.2 for both 32bit and 64 bit windows.
There are a whole lot of other compiled packages here, too.
Be sure to uninstall your old PILfirst.
If you used easy_install:
easy_install -mnX pil
And then remove the egg in python/Lib/site-packages
Be sure to remove any other failed attempts. I had moved the _image dll into Python*.*/DLLs and I had to remove it.
I've just had the same problem (with Python 2.7 and PIL for this versions, but the solution should work also for 2.6) and the way to solve it is to copy all the registry keys from:
HKEY_LOCAL_MACHINE\SOFTWARE\Python
to
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Python
Worked for me
solution found at the address below so credits should go there:
http://effbot.slinkset.com/items/Adding_Python_Information_to_the_Windows_Registry
Compiling PIL on Windows x64 is apparently a bit of a pain. (Well, compiling anything on Windows is a bit of a pain in my experience. But still.) As well as PIL itself you'll need to build many dependencies. See these notes from the mailing list too.
There's an unofficial precompiled binary for x64 linked from this message, but I haven't tried it myself. Might be worth a go if you don't mind the download being from one of those slightly dodgy file-upload sites. Other than that... well, you could always give up and instead the 32-bit Python binary instead.
If you installed a win64 python, you need a win64 PIL. The official PIL download site only has win32, as far as I can tell. The win32 installer will not see your 64-bit python installation.
No amount of tinkering with permissions or redistributables will fix this. You could use the win32 python instead (the Win64 python is mutant anyhow; Microsoft decided that C 'long' should be 32 bits in their 64-bit world, so python 'ints' are only 32 bits in Win64 python).
Since sizeof(long)!=sizeof(ptr) in win64, porting C extensions can be problematic, and will not be the same as porting them to linux 64. E.g. it seems that Win64 numpy is experimental/broken whereas linux64 numpy has been fine for years. My recommendation is if you use win64, stick with win32 python. If you want 64-bit python use linux.
I think I had a similar problem in the past, with another python library. I believe that it was a windows permission issue. Try adding "Users" to your python directory, and give them full access.
Make sure you have the Visual C++ Redistributable package installed on your machine.
Just got this error msg on my 32 bit Windows - I read the FAQ here: http://pythonware.com/products/pil/faq.htm and this sort of indicates that Windows is funny. Looked again at install pg and downloaded the Windows executable for Python26 # Python Imaging Library 1.1.7 for Python 2.6 (Windows only) - and the _imaging module gets installed when you run this. Should solve problem. So you can't just do the python setup.py install routine on: Python Imaging Library 1.1.7 Source Kit (all platforms) (November 15, 2009).
I was having the same problem so I decided to download the source kit and install it according to how you posted above...
Downloaded Source Kit
Opened command prompt on that folder and typed python setup.py build
Then I typed python setup.py install
It worked perfectly!
Now, some notes: when I typed python setup.py build, I saw that Microsoft Visual Studio v9.0 C compiler was being used to build everything.
So probably it's something with your compiler not correctly configured or something...
Anyways, that worked with me so thank you!
Pillow is new version
PIL-1.1.7.win-amd64-py2.x installers are available at
http://www.lfd.uci.edu/~gohlke/pythonlibs/#pil
http://www.lfd.uci.edu/~gohlke/pythonlibs/
press contrl F
type Pillow‑2.4.0.win‑amd64‑py3.3.exe
then click and downloadd the 64 bit version
Pillow is a replacement for PIL, the Python Image Library, which provides image processing functionality and supports many file formats.
Note: use from PIL import Image instead of import Image.
PIL‑1.1.7.win‑amd64‑py2.5.exe
PIL‑1.1.7.win32‑py2.5.exe
Pillow‑2.4.0.win‑amd64‑py2.6.exe
Pillow‑2.4.0.win‑amd64‑py2.7.exe
Pillow‑2.4.0.win‑amd64‑py3.2.exe
Pillow‑2.4.0.win‑amd64‑py3.3.exe
Pillow‑2.4.0.win‑amd64‑py3.4.exe
Pillow‑2.4.0.win32‑py2.6.exe
Pillow‑2.4.0.win32‑py2.7.exe
Pillow‑2.4.0.win32‑py3.2.exe
Pillow‑2.4.0.win32‑py3.3.exe
Pillow‑2.4.0.win32‑py3.4.exe

Categories

Resources