4

I am trying to create and save an stl file with a cube and I cannot import the mesh module for some reason. When hovering over mesh, it says: "Cannot find 'mesh' in '__init__.py'" I originally had the directory folder named stlExperiments but then someone said you cannot have stl in the name so I changed all instances of "stl" to "st" and no change, so I'm left to assume it's a completely different problem. Can anybody help? I am in the dark. The import code goes as follows:

from __future__ import absolute_import, division, print_function

import numpy as np
from stl import mesh

and the error message goes as follows:

Traceback (most recent call last): File "C:/Users/Riley/PycharmProjects/stExperiments/stCube.py", line 4, in from stl import mesh ImportError: cannot import name 'mesh'

Process finished with exit code 1

273K
  • 29,503
  • 10
  • 41
  • 64
Riley Fitzpatrick
  • 869
  • 2
  • 16
  • 38

2 Answers2

9

I had the same problem when installing stl with pip install stl

Try using pip install numpy-stl

It works on my computer (Windows 10)

NOTE:

if you are on python 3.x, simply change pip to pip3

Community
  • 1
  • 1
lsabi
  • 3,641
  • 1
  • 14
  • 26
0

I was facing the same error when running python3 myScript.py:

from stl import mesh

ModuleNotFoundError: No module named 'stl'

Virtual environment

It was resolved by creating a virtual environment and using it:

python3 -m venv virtual-environment
source virtual-environment/bin/activate
pip3 install numpy-stl
python3 myScript.py
Megidd
  • 7,089
  • 6
  • 65
  • 142