Mac OS Snow Leopard, IPython Notebook matplotlib backend mismatch with libpng - matplotlib

The other day I was trying to delve deeper into this question and provide some insights. Maybe with the additional insights it can finally be solved.
Things to note:
Installing a different Python version is not an option for me (I'd do it in a heartbeat) because I need to use the Gurobi linear programming solver.
matplotlib is compiled with libpng 1.5.14 and linked at runtime just fine. In the IPython console I can use it to plot png figures perfectly.
Because of the previous point I believe the error must occur with the backend used in the IPython Notebook which is also compiled with matplotlib.
I'm trying the whole thing with the source for matplotlib 1.3, if someone can make it work with a previous, not too old version I'd be happy, too.
So, when I try to plot something in the Notebook I get the normal text output from matplotlib put no figure. In the terminal where I started the notebook, I can see the following error:
libpng warning: Application built with libpng-1.2.41 but running with 1.5.14
Since I concluded earlier that the problem must lie in the backend, I checked what libraries are linked there:
otool -L /Library/Python/2.6/site-packages/matplotlib-1.3.0-py2.6-macosx-10.6-universal.egg/matplotlib/backends/_tkagg.so
The output on my system was:
/Library/Python/2.6/site-packages/matplotlib-1.3.0-py2.6-macosx-10.6-universal.egg/matplotlib/backends/_tkagg.so:
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 7.9.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.11)
/System/Library/Frameworks/Tcl.framework/Versions/8.5/Tcl (compatibility version 8.5.0, current version 8.5.7)
/System/Library/Frameworks/Tk.framework/Versions/8.5/Tk (compatibility version 8.5.0, current version 8.5.7)
So the likely offending candidates are Tcl and Tk. Then I ran:
find /System -name libpng\*
and indeed I find:
/System/Library/Tcl/8.4/Img1.4/libpngtcl1.2.24.dylib
/System/Library/Tcl/8.5/Img1.4/libpngtcl1.2.24.dylib
as well as Python shipping its own:
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/libpng.3.dylib
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/libpng.dylib
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/libpng12.0.dylib
/System/Library/Frameworks/Python.framework/Versions/2.6/lib/libpng12.dylib
I went ahead and downloaded the source code for Tcl/Tk 8.6 and compiled them myself in the hope of them compiling against libpng but that wasn't the case. I still got the same error:
libpng warning: Application built with libpng-1.2.41 but running with 1.5.14
When I compile matplotlib it says that due to patches it ships its own libagg and I can't find which tkagg it is using, so maybe that's where things go wrong? Or is the Python 2.6 provided by the system compiled with Tk which is linked against that older libpng?
I guess I could try compiling matplotlib against the libpng version of Tcl/Tk 8.5 or against the one available in the Python framework and see if then both run on libpng version 1.2.41.
Does anyone know where in the backend this might occur and how to fix the compilation to use the right libpng version?

Have you solved the problem yet? I have a similar issue, and I solved it by temporarily renaming the folder containing the header files of libpng shipped with Python (in my case, it's X11) when building matplotlib. After installing matplotlib, rename the folder back.

Related

How to upgrade gcc compiler to latest version

I have gcc 6.3.0 and to run tensorflow 2.11.0 along with cuda 11.2, I require gcc version 9.3.1, but I just cannot find a simple and straightforward way to do that. Some people say install mysys, other sites point to sourceforge download link, while download links on mingw site point to github repos, I just don't understand how to upgrade this thing.
It would be really helpful if someone could explain it like you are explaining it to complete newbie, step by step.
Last time, I downloaded mysys2 because someone told that it will automatically upgrade gcc to latest version, mysys2 came with a python 3.10, and I was working with python 3.9, and it created a lot of issues, later I had to reset my pc. That's way I just want to know the direct way to upgrade this thing instead of upgrading other software. I also tried by downloading mingw, but the installer available on sourceforge gives gcc 6.3.0 and not the latest gcc.
And what is this cygwin which gives unix like environment, why do i require unix like environment. Even if cygwin can do it easily, I am hesitant to download cygwin, cause i don't want another repeat of tragedy that happened due to mysys2, afterall, installing a complete set of programs that i don't know anything about and will probably never use will only create additional errors.

Packaging with Pyinstaller - PyQt5 setStyle ignored

I'm actually have an similar issue as described here after update python, pyistaller, pyqt5, pyqt5-tools. Before I got the desired "Windows Vista-style" without app.setStyle('windowsvista') when I run the compiled stand-alone executable.
Now I got the Windows "Classic-style" instead. If I start the application in PyCharm it will use the desired "Windows Vista-style".
Currently installed on Win7 64bit:
Python : 3.6.4
PyInstaller: 3.3.1
PyQt5 : 5.10
pyqt5-tools: 5.9.0.1.2 (update to 5.9.1.1 doesn't work)
Does anyone have any idea why PyInstaller ignored the style?
The error seems to have been fixed in a unmerged branch of PyInstaller. More information can be found on the GitHub pull request conversation, but reinstalling PyInstaller using pip install https://github.com/bjones1/pyinstaller/archive/pyqt5_fix.zip fixed the same style issue for me on Mac.

pyinstaller with matplotlib windows

I use pyinstaller in generate pythion program with matplotlib a exe file
The exe is generated well but when use the exe, there is a error said no module named 'tz'
what does it mean?
I have test the pythinstaller with program with numby and pyqt4 without matplotlib, it worksenter image description here well! )
I have find the solution on pyinstaller git hub provided by Cecil Curry.
It is:
This is a known issue. python-dateutil 2.5.0 is currently broken with respect to PyInstaller, unfortunately.
Until python-dateutil issues a new stable release correcting this, consider temporarily downgrading to python-dateutil 2.4.2. Apologies for the mild inconvenience – and thanks for taking the time to report this, nonetheless.
I have tested and it works

Forced to install GDAL 1.11 framework by package for QGIS, and failing

To install QGIS on my MacBook Pro I need to install the gdal framework; however, the 1.11 framework package needed for QGIS is an empty file at kyngchaos. I tried installing GDAL 1.10 complete, but QGIS is requiring 1.11. I have Mavericks. I've installed each individual package: UnixImageIO, PROJ, GEOS, SQLite2, numpy, rgdal, and on... Now when I run the GDAL 1.11 framework install, everything seems to run until the last page, where an "Install Fail" page shows up. When I try to view the error, I'm taken out of the installer.
After some googling, I tried installing using homebrew. (brew install gdal)... I got a little further, but it tells me to "brew link libpng libtiff" -- and when I run that command, I get:
Linking /usr/local/Cellar/libpng/1.5.14... Warning: Could not link libpng. Unlinking...
Error: Could not symlink file: /usr/local/Cellar/libpng/1.5.14/share/man/man3/libpngpf.3
/usr/local/share/man/man3 is not writable. You should change its permissions.
After some more searching, it seems I could change permissions from usr/local to me, but I'm not sure how to (exactly) and don't want to mess anything up. Any help would be greatly appreciated, and my apologies if I'm missing something painfully obvious! I'm a novice at the programming end of things, so am just kind of pushing through everything like a bull in a china shop.
UPDATE:
Okay, I found the answer, even though it didn't seem to be working initially--
I ran the following commands from the GDAL help documentation:
export PATH=/Library/Frameworks/GDAL.framework/Programs:$PATH
sudo ln -sfh [ver] /Library/Frameworks/GDAL.framework/Versions/Current
in Terminal, and the framework was updated. If I run the GDAL 1.11 installer it still shows up as a failed installation, BUT QGIS recognizes 1.11 as the installed, so that's great.
(I just needed to install matplotlib in addition, and QGIS was installed successfully.)
It seems that the GDAL Complete framework was just updated 3 days ago, so it should be a temporary error until they realize the package is empty.

installing matplotlib on ubuntu?

I have:
Ubuntu 8.04
python 2.5.2 installed on this Ubuntu
matplotlib 0.92.0 installed
I want to upgrade to (atleast) matplotlib 0.99
so that I can do 3d plotting.
The synaptic package (also the command line apt-get)
tells me that whatever I have is the latest matplotlib (which is not true).
How can I install matplotlib 0.99 or matplotlib 1.0.1 ?
You have the latest available package version for your operating system. Given that Ubuntu is at version 11 now and you are using 8.04, the version difference in the matplotlib package might not come as very surprising.
As for installing the newest version, I'd suggest reading:
http://matplotlib.sourceforge.net/faq/installing_faq.html
...if all fails, you can always install from source.
Note that support for Desktop versions of 8.04 LTS is due to expire shortly -- if this is a desktop machine, perhaps the easiest answer is to upgrade to 10.04 LTS, 10.10, or the very-soon-upcoming 11.04 release (or whatever they'll call the next release). Maybe not "the easiest answer", but an answer that includes security updates for Mozilla, Adobe Flash, the Kernel, and so forth.
Many newer versions of packages are supported via the Ubuntu Backports facility, but I didn't spot python-matplotlib in the list of available packages. Perhaps they would provide it if you asked nicely, perhaps it would be too much work.
You can always try installing newer versions from newer releases, but newer versions of python and libraries might introduce worse problems. (But probably will work fine.) See the apt_preferences(5) manpage for details on how to configure multiple APT sources and select some specific packages from a newer distribution (pinning), and rely on the older distribution for all the other packages.
Jim's answer of building the version you need from source is probably your best second option, if installing a newer version of the distribution is too daunting / otherwise impossible at this point.