我打算用 Python 为 raspberrypi 编写一个程序,以导入 3D STL 图像。
为此,我搜索了一个名为“ numpy-stl ”的 Python 库,它适合我的要求。我按照网站的说明安装
sudo pip install numpy-stl
然后尝试从示例中运行给定的代码。
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')
但现在我面临以下错误:
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
有人可以指导我如何解决此错误吗?谢谢