Opened 6 months ago

Closed 6 months ago

Last modified 6 months ago

#69546 closed defect (fixed)

py312-matplotlib fails to install on eMac with Leopard 10.5.8 - all dependencies installed.

Reported by: ilovecrts Owned by: reneeotten (Renee Otten)
Priority: Normal Milestone:
Component: ports Version: 2.9.1
Keywords: Cc:
Port: py-matplotlib

Description

I have been trying to install py312-matplotlib with "sudo port install py312-matplotlib".

I am doing this on an eMac running Leopard 10.5.8.

All the dependencies installed successfully! Hooray!

Now I just need to get matplotlib installed. Here is the terminal output when I attempt to install.

XXXXX:~ YYYYY$ sudo port clean py312-matplotlib
--->  Cleaning py312-matplotlib
XXXXX:~ YYYYY$ sudo port install py312-matplotlib
--->  Computing dependencies for py312-matplotlib
--->  Fetching archive for py312-matplotlib
--->  Attempting to fetch py312-matplotlib-3.5.3_1+cairo+webagg.darwin_9.ppc.tbz2 from http://packages.macports.org/py312-matplotlib
--->  Attempting to fetch py312-matplotlib-3.5.3_1+cairo+webagg.darwin_9.ppc.tbz2 from http://mirror.fcix.net/macports/packages/py312-matplotlib
--->  Attempting to fetch py312-matplotlib-3.5.3_1+cairo+webagg.darwin_9.ppc.tbz2 from http://ywg.ca.packages.macports.org/mirror/macports/packages/py312-matplotlib
--->  Fetching distfiles for py312-matplotlib
--->  Verifying checksums for py312-matplotlib
--->  Extracting py312-matplotlib
--->  Applying patches to py312-matplotlib
--->  Configuring py312-matplotlib
--->  Building py312-matplotlib
Error: Failed to build py312-matplotlib: command execution failed
Error: See /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_python_py-matplotlib/py312-matplotlib/main.log for details.
Error: Follow https://guide.macports.org/#project.tickets if you believe there
is a bug.
Error: Processing of port py312-matplotlib failed
XXXXX:~ YYYYY$

I examined the main.log file referenced above. Yikes, it's big!

The error messages only appear at the end.

:info:build src/qhull_wrap.cpp: In function ‘PyObject* delaunay_impl(npy_intp, const double*, const double*, bool)’:
:info:build src/qhull_wrap.cpp:179: error: ‘class std::vector<double, std::allocator<double> >’ has no member named ‘data’
:info:build src/qhull_wrap.cpp: In function ‘PyObject* delaunay(PyObject*, PyObject*)’:
:info:build src/qhull_wrap.cpp:290: warning: ‘Py_VerboseFlag’ is deprecated (declared at /opt/local/Library/Frameworks/Python.framework/Versions/3.12/include/python3.12/cpython/pydebug.h:9)
:info:build error: command '/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_python_py-matplotlib/py312-matplotlib/work/compwrap/cc/usr/bin/gcc-4.2' failed with exit code 1
:info:build Command failed:  cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_python_py-matplotlib/py312-matplotlib/work/matplotlib-3.5.3" && /opt/local/Library/Frameworks/Python.framework/Versions/3.12/bin/python3.12 setup.py --no-user-cfg build 
:info:build Exit code: 1
:error:build Failed to build py312-matplotlib: command execution failed
:debug:build Error code: CHILDSTATUS 522 1
:debug:build Backtrace: command execution failed
:debug:build     while executing
:debug:build "system {*}$notty {*}$callback {*}$nice $fullcmdstring"
:debug:build     invoked from within
:debug:build "command_exec -callback portprogress::target_progress_callback build"
:debug:build     (procedure "portbuild::build_main" line 10)
:debug:build     invoked from within
:debug:build "$procedure $targetname"
:error:build See /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_macports_release_tarballs_ports_python_py-matplotlib/py312-matplotlib/main.log for details.

I am a novice here and I do not understand the error here. I am early in my learning journey. :)

I am attaching the main.log file to this ticket.

Can someone explain what is going on, why this error occurred, and how we can fix this so matplotlib installs?

Thank you for your help and support!

Attachments (3)

main.log (215.9 KB) - added by ilovecrts 6 months ago.
main.log for failed py312-matplotlib installation on eMac with Leopard 10.5.8
reinstalling_matplotlib.txt (12.3 KB) - added by ilovecrts 6 months ago.
Terminal output of second installation attempt.
main (second attempt).log (327.8 KB) - added by ilovecrts 6 months ago.
main.log for second failed py312-matplotlib installation on eMac with Leopard 10.5.8

Download all attachments as: .zip

Change History (23)

Changed 6 months ago by ilovecrts

Attachment: main.log added

main.log for failed py312-matplotlib installation on eMac with Leopard 10.5.8

comment:1 Changed 6 months ago by ilovecrts

Hello,

Has anyone had a chance to take a look at this ticket?

Thanks! :)

comment:2 Changed 6 months ago by kencu (Ken)

ChatGPT:

The error message you're encountering indicates that you're trying to access the data member of a std::vector<double>, but the data member does not exist for std::vector prior to C++11. The data member function was introduced in C++11.

If you're using a compiler that supports C++11 or later standards, you can fix this error by ensuring that your compiler is set to use the correct language standard.

---

so if we set this in the portfile somewhere, somehow, and make sure it takes effect:

compiler.cxx_standard 2011

we should be good to go

comment:3 Changed 6 months ago by ilovecrts

Hi Ken,

Thank you for the reply!

Can you tell me where the portfile is located? I searched for "portfile" via Finder and am getting thousands of results.

Is this portfile specific to py312-matplotlib or MacPorts?

comment:4 Changed 6 months ago by kencu (Ken)

port file py312-matplotlib

will show it to you.

comment:5 Changed 6 months ago by reneeotten (Renee Otten)

In 4b0f9ed1283d738da7b77cc9595b598a5e838376/macports-ports (master):

py-matplotlib: require C++11 compatible compiler

See: #69546

comment:6 Changed 6 months ago by reneeotten (Renee Otten)

Owner: set to reneeotten
Port: py-matplotlib added; py312-matplotlib removed
Status: newaccepted

As Ken pointed out I added the line to request a C++11 compatible compiler to the Portfile. Once that change has propagated to the mirrors (likely in the next few hours) you will get the change after doing port selfupdate and you can try to install py312-matplotlib again. I don't have such an old OS to actually test it, but ideally this should be sufficient... Please let us know if that worked for you; if not, please make sure to add the new main.log file from an installation after you have done sudo port clean --all py312-matplotlib.

comment:7 Changed 6 months ago by ilovecrts

Ken and Renee,

Thank you for your responses!

I did not see the "port file" command in the online documentation. Now I feel like I know a secret. :)

I ran "sudo port selfupdate" and it looks like my local ports tree was updated. Hopefully this update includes yours.

Now I am running "sudo port install py312-matplotlib". Oh my! Packages are being fetched, extracted, configured, and built and more. This is exciting! Unfortunately, my eMac needs a lot of time to do all of this. :( I will let it run peacefully and check back in once the process is complete.

Thank you again for your support! This is all new to me and very challenging, but I am enjoying my climb up this steep learning curve. :)

comment:8 Changed 6 months ago by ilovecrts

My re-installation attempts failed.

I realized after my post that I forgot to run sudo port clean --all py312-matplotlib! The installation failed. :(

After the failure, I ran sudo port clean --all py312-matplotlib, followed by sudo port selfupdate. Then I re-ran the installation. It failed again.

The main.log file is big and has a warning here and there, I think. Maybe nothing special?

The errors are at the very end.

I will attach noth my terminal output and my main.log file are attached here.

Maybe I should have given more time for the fix to propagate in MacPorts? I will try again tomorrow afternoon. Any reason to fire up my eMac is a good one! :)

Thank you again for your help and support, Ken and Renee!

Changed 6 months ago by ilovecrts

Attachment: reinstalling_matplotlib.txt added

Terminal output of second installation attempt.

Changed 6 months ago by ilovecrts

Attachment: main (second attempt).log added

main.log for second failed py312-matplotlib installation on eMac with Leopard 10.5.8

comment:9 Changed 6 months ago by kencu (Ken)

I have this building all the deps now -- let's see if we can get this done for you.

comment:10 Changed 6 months ago by reneeotten (Renee Otten)

it doesn't look like that you got the updated Portfile yet, at least it's still using gcc-4.2 as the compiler and that shouldn't happen with compiler.cxx_standard 2011 present in the Portfile...

Thank you Ken for looking at this and firing up your old system to help with this; you're in luck @ilovecrts if anyone will get this sorted out for you it's Ken - our guru for older OSes.

comment:11 Changed 6 months ago by kencu (Ken)

Resolution: fixed
Status: acceptedclosed

The current Portfile installed overnight on my 10.5 PPC system without touching anything, so it looks good to me:

$ port -v installed py312-matplotlib
The following ports are currently installed:
  py312-matplotlib @3.5.3_1+cairo+webagg (active) requested_variants='' platform='darwin 9' archs='ppc' date='2024-03-23T00:15:29-0700'

If you clean the previous build again, update your ports tree to pull in the latest updates, and try again you should be fine.

comment:12 Changed 6 months ago by ilovecrts

Hello Ken and Renee!

Hooray! I was able to successfully build matplotlib on my eMac following your instructions! :) :) Thank you very, very much to the both of you! :) :)

XXXXX:~ YYYYY$ sudo port clean py312-matplotlib
Password:
--->  Cleaning py312-matplotlib
XXXXX:~ YYYYY$ sudo port selfupdate
--->  Updating MacPorts base sources using rsync
MacPorts base version 2.9.1 installed,
MacPorts base version 2.9.1 downloaded.
--->  Updating the ports tree
--->  MacPorts base is already the latest version

The ports tree has been updated. To upgrade your installed ports, you should run
  port upgrade outdated
XXXXX:~ YYYYY$ sudo port install py312-matplotlib
Password:
--->  Computing dependencies for py312-matplotlib
--->  Fetching archive for py312-matplotlib
--->  Attempting to fetch py312-matplotlib-3.5.3_1+cairo+webagg.darwin_9.ppc.tbz2 from http://mirror.fcix.net/macports/packages/py312-matplotlib
--->  Attempting to fetch py312-matplotlib-3.5.3_1+cairo+webagg.darwin_9.ppc.tbz2 from http://packages.macports.org/py312-matplotlib
--->  Attempting to fetch py312-matplotlib-3.5.3_1+cairo+webagg.darwin_9.ppc.tbz2 from http://kmq.jp.packages.macports.org/py312-matplotlib
--->  Fetching distfiles for py312-matplotlib
--->  Verifying checksums for py312-matplotlib
--->  Extracting py312-matplotlib
--->  Applying patches to py312-matplotlib
--->  Configuring py312-matplotlib
--->  Building py312-matplotlib
--->  Staging py312-matplotlib into destroot             
--->  Installing py312-matplotlib @3.5.3_1+cairo+webagg  
--->  Activating py312-matplotlib @3.5.3_1+cairo+webagg
--->  Cleaning py312-matplotlib
--->  Updating database of binaries
--->  Scanning binaries for linking errors
--->  No broken files found.                             
--->  No broken ports found.
--->  Some of the ports you installed have notes:
  py312-matplotlib has the following notes:
    The default backend is the interactive Mac OS X backend. Different backends can be specified using the ~/.matplotlib/matplotlibrc file. More details regarding
    backends can be found in the matplotlib FAQ:
    
            https://matplotlib.org/stable/users/explain/backends.html
XXXXX:~ YYYYY$

Unfortunately, I am running into a new problem. :(

I want to test the matplotlib installation by making a very simple plot based on an example shown in the matplotlib tutorial documentation.

https://matplotlib.org/stable/tutorials/pyplot.html

import matplotlib.pyplot as plt

plt.plot([1, 2, 3, 4])
plt.ylabel('some numbers')
plt.show()

I get an error when I import matplotlib. :(

XXXXX:~ YYYYY$ python3
Python 3.12.2 (main, Mar 13 2024, 18:40:15) [GCC 7.5.0] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib.pyplot as plt
Python(1098) malloc: *** error for object 0xa06da3dc: Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
Python(1098) malloc: *** error for object 0xa06da36c: Non-aligned pointer being freed
*** set a breakpoint in malloc_error_break to debug
Matplotlib is building the font cache; this may take a moment.
>>>

This behavior is repeatable except I get a different 4 digit number in the "Python(1098)" string.

If I go further with the tutorial example I get the following error.

>>> plt.plot([1, 2, 3, 4])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/matplotlib/pyplot.py", line 2767, in plot
    return gca().plot(
           ^^^^^
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/matplotlib/pyplot.py", line 2272, in gca
    return gcf().gca(**kwargs)
           ^^^^^
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/matplotlib/pyplot.py", line 865, in gcf
    return figure()
           ^^^^^^^^
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/matplotlib/pyplot.py", line 806, in figure
    manager = new_figure_manager(
              ^^^^^^^^^^^^^^^^^^^
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/matplotlib/pyplot.py", line 324, in new_figure_manager
    _warn_if_gui_out_of_main_thread()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/matplotlib/pyplot.py", line 314, in _warn_if_gui_out_of_main_thread
    if (_get_required_interactive_framework(_get_backend_mod())
                                            ^^^^^^^^^^^^^^^^^^
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/matplotlib/pyplot.py", line 217, in _get_backend_mod
    switch_backend(dict.__getitem__(rcParams, "backend"))
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/matplotlib/pyplot.py", line 282, in switch_backend
    class backend_mod(matplotlib.backend_bases._Backend):
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/matplotlib/pyplot.py", line 283, in backend_mod
    locals().update(vars(importlib.import_module(backend_name)))
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/matplotlib/backends/backend_macosx.py", line 4, in <module>
    from matplotlib.backends import _macosx
ImportError: cannot import name '_macosx' from 'matplotlib.backends' (/opt/local/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/matplotlib/backends/__init__.py)
>>> 

Despite matplotlib building correctly, is there something else buggy under the hood or is there something wrong with my eMac? Should I open a new ticket here?

Thank you both again - especially Ken! I really appreciate the time you are investing here. :)

comment:13 Changed 6 months ago by kencu (Ken)

this error:

error for object 0xa06da3dc: Non-aligned pointer being freed

represents an unfavourable interaction between the new libstdc++.dylib from the gcc7/libgcc7 ports, and the old old /usr/lib/libstdc++.dylib that comes with Leopard 10.5.

Basically, an object is being created using one libstdc++, then passed to the other one. But the library has changed, and the objects no longer match.

We have a workaround for this issue, but it requires identifying exactly which executable is triggering the error.

comment:14 Changed 6 months ago by ilovecrts

Hi Ken,

Thanks for the reply!

Is there a debug process I can follow to identify the specific executable triggering this error?

comment:15 Changed 6 months ago by kencu (Ken)

trial and error

comment:16 Changed 6 months ago by ilovecrts

Hi Ken,

Was a ticket about this logged that I can read? I need some clues on where to even begin. :)

One trial I did just now was install Xquartz 2.6.3. It didn't affect the import error I am receiving. :(

Thanks!

-=- Boirs

comment:17 Changed 6 months ago by kencu (Ken)

ah, we need to fix this Xquartz business once and for all.

You should install xorg-server-legacy from MacPorts instead, as it's much newer and has been updated many times.

comment:18 Changed 6 months ago by kencu (Ken)

So to workaround the libstdc++.dylib issue, we need to do this:

LeopardG5:~$ export DYLD_LIBRARY_PATH=/opt/local/lib/libgcc
LeopardG5:~$ python3
Python 3.12.2 (main, Feb 22 2024, 16:48:13) [GCC 7.5.0] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib.pyplot as plt

setting DYLD_LIBRARY_PATH=/opt/local/lib/libgcc in the environment before you start running anything tells the library locating software in MacOSX to first look in /opt/local/lib/libgcc for any libraries it is trying to load.

Those libraries are our new ones (which we need for the newer compiler). The old software that has been built against /usr/lib/libstdc++.6.dylib on your system seems to be quite happy using that newer libstdc++.6.dylib, and so there is no confusion about the objects that will be created and passed back and forth.

I will say that even though setting $ export DYLD_LIBRARY_PATH=/opt/local/lib/libgcc fixes the loading problem, other errors do show up soon after with other things.

I know very little about matplotlib, and only slightly more about python, so for those issues, you might open a new ticket with that specific error and perhaps someone who does know about those things will catch an interest and help you out with that.

Now -- will everyone who uses matplotlib on 10.5 PPC need to set export DYLD_LIBRARY_PATH=/opt/local/lib/libgcc? Or is there some way to automate that? -- I can't see an easy way to automate that just now -- I think you're stuck exporting it whenever you want to use matplotlib, at the moment.

comment:19 Changed 6 months ago by kencu (Ken)

It looks like you'll need to play around with things a bit and sort out which backend matplotlib can use on 10.5 PPC.

There are a number of them:

 ['GTK3Agg', 'GTK3Cairo', 'GTK4Agg', 'GTK4Cairo', 'MacOSX', 'nbAgg', 'QtAgg', 'QtCairo', 'Qt5Agg', 'Qt5Cairo', 'TkAgg', 'TkCairo', 'WebAgg', 'WX', 'WXAgg', 'WXCairo', 'agg', 'cairo', 'pdf', 'pgf', 'ps', 'svg', 'template']

and it looks like you set them like this:

import matplotlib
matplotlib.use('THE_BACKEND')
import matplotlib.pyplot as plt

I tried GTK3Cairo. It asked for py312-gobject3, which I installed. After that, it seemed to do your plot of 1,2,3,4 OK, but -- nothing showed up on the screen anywhere.

I'm sure I'm missing something. Perhaps you need to use 'gnuplot' or 'aquaterm' to get this to work, or maybe a different backend is a better option.

comment:20 Changed 6 months ago by ilovecrts

Hi Ken,

Thanks for the replies! :)

I am installing xorg-server-legacy on my eMac now. There are lots of libraries it depends on that need to be installed. I have a feeling this will take a few hours.

Do I need to do anything to uninstall Xquartz or should I simply leave it be? I was working through some tkinter tutorials with it last night. My little windows and widgets seemed to work. :) :)

After xorg-server-legacy is successfully installed (fingers crossed!), I will try your workaround in comment #18. You said I may see other errors pop up afterwards. Do you think that may have something to do with the backend? I will definitely try installing the different backends you mention in comment #19. It seems simple enough and harmless enough to do. Just takes time on my eMac.

I will log a new ticket if I see new errors. Hopefully we'll be able to squash them! :)

Thanks again for your replies and your support!

Note: See TracTickets for help on using tickets.