Importing of 3D STL Image in Python (ImportError: No module named ascii)
This should be solved once you update numpy-stl.
And more importantly, remove any other stl
package -
otherwise you have a clash with the module name. (The package numpy-stl is imported as import stl
.)
If the package stl 0.0.3 is installed, uninstall it first:
pip uninstall stl
Then the package numpy-stl should work as expected (i.e. it can be used via import stl
), as soon as it is installed:
pip install numpy-stl
Comments
-
Irfan Ghaffar7 almost 2 years
I am planning to write a program in Python for raspberrypi, to import a 3D STL image.
For that purpose, I googled and got a Python library called "numpy-stl" which is suitable for my requirement. I install it according to the instructions of website
sudo pip install numpy-stl
Then try to Run given Code from example.
from stl import mesh # Using an existing stl file: mesh = mesh.Mesh.from_file('some_file.stl') # Or creating a new mesh: VERTICE_COUNT = 100 data = numpy.zeros(VERTICE_COUNT, dtype=Mesh.dtype) mesh = mesh.Mesh(data, remove_empty_areas=False) # The mesh normals (calculated automatically) mesh.normals # The mesh vectors mesh.v0, mesh.v1, mesh.v2 # Accessing individual points (concatenation of v0, v1 and v2 in triplets) mesh.points[0] == mesh.v0[0] mesh.points[1] == mesh.v1[0] mesh.points[2] == mesh.v2[0] mesh.points[3] == mesh.v0[1] mesh.save('new_stl_file.stl')
But now I am facing below error:
Traceback (most recent call last): File "/home/pi/checkstl.py", line 1, in <module> from stl import stl File "/usr/local/lib/python2.7/dist-packages/stl/__init__.py", line 2, in <module> import stl.ascii ImportError: No module named ascii
Can anybody please guide me on how do I resolve this error? Thank you