BlackJerry
BlackJerry

Reputation: 88

Pymeshlab, more specifically, pymeshlab.Mesh(), crashes on multiple computers

I have been struggling with this for a few days and now I am at my wits' end. Need some help here.

I am not able to get Pymeshlab up and running. I have tried on multiple computers, my Windows 11 PC, Macbook Pro, and two Google Compute Engine Virtual Machines with Ubuntu 22.04. They either have Python 3.9 or 3.11. After install Pymeshlab, even the simplest code of

    import pymeshlab
    pymeshlab.Mesh()

causes segmentation fault (core dump). No other error messages. Just crashes Python and exit to the terminal prompt.

I also tested to create a non empty mesh using the sample code here . The pytest as shown in the page works (not causing segmentation fault. But I am not sure what it does). But if I actually run the code in the script in Python:

    # sample code to create a non empty pymeshlab mesh
    import pymeshlab
    import numpy
    # create a numpy 8x3 array of vertices
    # columns are the coordinates (x, y, z)  
    # every row represents a vertex
    verts = numpy.array([
        [-0.5, -0.5, -0.5],
        [0.5, -0.5, -0.5],
        [-0.5, 0.5, -0.5],
        [0.5, 0.5, -0.5],
        [-0.5, -0.5, 0.5],
        [0.5, -0.5, 0.5],
        [-0.5, 0.5, 0.5],
        [0.5, 0.5, 0.5]])

    # create a numpy 12x3 array of faces
    # every row represents a face (triangle in this case)
    # for every triangle, the index of the vertex
    # in the vertex array
    faces = numpy.array([
        [2, 1, 0],
        [1, 2, 3],
        [4, 2, 0],
        [2, 4, 6],
        [1, 4, 0],
        [4, 1, 5],
        [6, 5, 7],
        [5, 6, 4],
        [3, 6, 7],
        [6, 3, 2],
        [5, 3, 7],
        [3, 5, 1]])
    
    # create a new Mesh with the two arrays
    m = pymeshlab.Mesh(verts, faces)

The last line will cause a segmentation fault (core dump) and cause Python to terminate.

This is rather surprising to me because this seems to be a popular package. But I couldn't get it to work on any of the 4 machines!

I wonder what I am doing wrong. Do I need to install meshlab before install Pymeshlab as mentioned here, or any other dependencies? I did install meshlab on a few of these machines later. It didn't help. I also tried to install xvfb as mentioned in the link to no avail.

Since I simply installed with "pip3 install pymeshlab", the version is 2023.12.post1.

Tried pip install pymeshlab on a Windows 11 PC, a Macbook Pro, and two GCE Ubuntu 22.04 virtual machines.

Upvotes: 1

Views: 278

Answers (1)

BlackJerry
BlackJerry

Reputation: 88

Answer my own question here.

Apparently, pymeshlab 2023.12.post1 does not work with numpy>=2.0. If you want to keep pymeshlab 2023.12.post1, downgrade numpy to 1.26.

Thankfully, pymeshlab 2023.12.post2 that just came out works with numpy>=2.0.

Upvotes: 0

Related Questions