7

I am trying to load/read a ply file using PyMesh and this line command:

mesh = pymesh.load_mesh("model.obj")

as it is in http://pymesh.readthedocs.io/en/latest/basic.html.

But this gives me an error "AttributeError: 'module' object has no attribute 'load_mesh'".

Am I doing anything wrong? Also I want to know if PyMesh really allows to visualize in 3d the objects.

Thank you.

rici
  • 234,347
  • 28
  • 237
  • 341
Bárbara Duarte
  • 529
  • 3
  • 9
  • 17

5 Answers5

13

If you installed with pip, you might not have gotten the pymesh module you were intending to use. Since you're looking for the load_mesh() method, you'll want to use this installation guide: http://pymesh.readthedocs.io/en/latest/installation.html.

Alex Kelly
  • 131
  • 1
  • 3
  • 2
    @Bárbara Duarte : following the build and install steps in this doc page made it work for me. I am upvoting this answer and suggest you select it as the answer. – ximiki Feb 10 '17 at 21:40
  • 1
    This is definitely the solution to the problem. The [Python Package Index page for pymesh](https://pypi.python.org/pypi/pymesh) differs is a completely different package that only supports loading STL and OBJ files. This answer links the appropriate package for the pymesh package the OP is looking for. – ephsmith Mar 01 '17 at 02:09
8

There are actually two modules named pymesh.

Pymesh by Takuro Wada

If you install pymesh using pip you are installing this one which has the following GitHub page.

It reads: .sty and .obj

Pymesh by Qingnan Zhou

If you want to install http://pymesh.readthedocs.io/en/latest/ you have to follow the installation guidelines here.

It is more complex, I never manage to get it working, but it should read also .ply.

G M
  • 20,759
  • 10
  • 81
  • 84
  • 1
    I managed to compile https://pymesh.readthedocs.io/en/latest/ with no problem. In Ubuntu 16.04 I only had to manually update my cmake to fulfill dependencies. – Dan Mar 08 '19 at 13:45
3

On a side note, meshio (one of my projects) now supports PLY as well. Install with

pip3 install meshio

and use on the command line like

meshio-convert in.ply out.vtk

or from within Python like

import meshio

mesh = meshio.read("in.ply")
# mesh.points, mesh.cells, ...
Nico Schlömer
  • 53,797
  • 27
  • 201
  • 249
0

Since you are look for load_mesh() method, i think that you are looking for this library. This is the related doc.

If true, you have to install pymesh2

pip install pymesh2

Otherwise you have to follow the instructions contained in that page as already suggested, but they are more complex.

Sankios
  • 183
  • 1
  • 7
-5

Either you have not imported the pymesh library

import pymesh

OR

You have a file named pymesh.py in your directory where you are executing this file.

If this is the case, then rename the file to some other name.

hungry_python
  • 13
  • 1
  • 6
  • Thanks for your answer. I import pymesh and there isn't a file with name pymesh.py. The import is ok, but the error is about "load_mesh" function. I don't know if I am using the right library, because I find this http://pymesh.readthedocs.io/en/latest/ and this https://pypi.python.org/pypi/pymesh. Is it the same? The tutorial of each one is different. – Bárbara Duarte May 06 '16 at 09:10
  • I need to open ply files, but in pymesh page (https://github.com/taxpon/pymesh) says that just opens STL & OBJ. I am confused. – Bárbara Duarte May 06 '16 at 09:20
  • Alex's answer is more likely the case, pip install pymesh gets a different package than the one OP is looking to use (based on the doc he provides). – NLi10Me Mar 14 '18 at 21:20