!pip3 install numpy-stl
Collecting numpy-stl
  Downloading numpy-stl-2.16.3.tar.gz (772 kB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
Requirement already satisfied: numpy in c:\users\user\anaconda3\lib\site-packages (from numpy-stl) (1.20.3)
Collecting python-utils>=1.6.2
  Downloading python_utils-3.1.0-py2.py3-none-any.whl (19 kB)
Building wheels for collected packages: numpy-stl
  Building wheel for numpy-stl (setup.py): started
  Building wheel for numpy-stl (setup.py): finished with status 'done'
  Created wheel for numpy-stl: filename=numpy_stl-2.16.3-py3-none-any.whl size=18681 sha256=9a1339fe04fa5e4b9a400e52aeaae2632b06e34a24894e7b725bd0e5682974aa
  Stored in directory: c:\users\user\appdata\local\pip\cache\wheels\7b\88\2c\67664b1fdf39d3893438773487d822a54396ce35e906f0cc10
Successfully built numpy-stl
Installing collected packages: python-utils, numpy-stl
Successfully installed numpy-stl-2.16.3 python-utils-3.1.0
import os
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.colors as colors
import numpy as np
from stl import mesh

# Define the 8 vertices of the cube
vertices = np.array([\
    [-1, -1, -1],
    [+1, -1, -1],
    [+1, +1, -1],
    [-1, +1, -1],
    [-1, -1, +1],
    [+1, -1, +1],
    [+1, +1, +1],
    [-1, +1, +1]])
# Define the 12 triangles composing the cube
faces = np.array([\
    [0,3,1],
    [1,3,2],
    [0,4,7],
    [0,7,3],
    [4,5,6],
    [4,6,7],
    [5,1,2],
    [5,2,6],
    [2,3,6],
    [3,7,6],
    [0,1,5],
    [0,5,4]])

# Create the mesh
cube = mesh.Mesh(np.zeros(faces.shape[0], dtype=mesh.Mesh.dtype))
for i, f in enumerate(faces):
    for j in range(3):
        print(vertices[f[j],:])
        cube.vectors[i][j] = vertices[f[j]]

# Write the mesh to file "cube.stl"
cube.save('cube.stl')
[-1 -1 -1]
[-1  1 -1]
[ 1 -1 -1]
[ 1 -1 -1]
[-1  1 -1]
[ 1  1 -1]
[-1 -1 -1]
[-1 -1  1]
[-1  1  1]
[-1 -1 -1]
[-1  1  1]
[-1  1 -1]
[-1 -1  1]
[ 1 -1  1]
[1 1 1]
[-1 -1  1]
[1 1 1]
[-1  1  1]
[ 1 -1  1]
[ 1 -1 -1]
[ 1  1 -1]
[ 1 -1  1]
[ 1  1 -1]
[1 1 1]
[ 1  1 -1]
[-1  1 -1]
[1 1 1]
[-1  1 -1]
[-1  1  1]
[1 1 1]
[-1 -1 -1]
[ 1 -1 -1]
[ 1 -1  1]
[-1 -1 -1]
[ 1 -1  1]
[-1 -1  1]
from PIL import Image
import matplotlib.pyplot as plt
im = Image.open("data/images/ctl.jpg")
plt.imshow(im)
<matplotlib.image.AxesImage at 0x17d6ca3f6a0>
grey_img = Image.open('data/images/ctl.jpg').convert('L')
plt.imshow(grey_img)
<matplotlib.image.AxesImage at 0x17d71798d30>
import numpy as np
from stl import mesh

# Define the 8 vertices of the cube
vertices = np.array([\
    [-1, -1, -1],
    [+1, -1, -1],
    [+1, +1, -1],
    [-1, +1, -1]])

# Define the 12 triangles composing the cube
faces = np.array([\
    [1,2,3],
    [3,1,0]
])

# Create the mesh
cube = mesh.Mesh(np.zeros(faces.shape[0], dtype=mesh.Mesh.dtype))
for i, f in enumerate(faces):
    for j in range(3):
        cube.vectors[i][j] = vertices[f[j],:]

# Write the mesh to file "cube.stl"
cube.save('surface.stl')
grey_img = Image.open('data/images/ctl.jpg').convert('L')

max_size=(500,500)
max_height=10
min_height=0

#height=0 for minPix
#height=maxHeight for maxPIx

grey_img.thumbnail(max_size)
imageNp = np.array(grey_img)
maxPix=imageNp.max()
minPix=imageNp.min()



print(imageNp)
(ncols,nrows)=grey_img.size

vertices=np.zeros((nrows,ncols,3))

for x in range(0, ncols):
  for y in range(0, nrows):
    pixelIntensity = imageNp[y][x]
    z = (pixelIntensity * max_height) / maxPix
    #print(imageNp[y][x])
    vertices[y][x]=(x, y, z)

faces=[]

for x in range(0, ncols - 1):
  for y in range(0, nrows - 1):
    # create face 1
    vertice1 = vertices[y][x]
    vertice2 = vertices[y+1][x]
    vertice3 = vertices[y+1][x+1]
    face1 = np.array([vertice1,vertice2,vertice3])

    # create face 2 
    vertice1 = vertices[y][x]
    vertice2 = vertices[y][x+1]
    vertice3 = vertices[y+1][x+1]

    face2 = np.array([vertice1,vertice2,vertice3])

    faces.append(face1)
    faces.append(face2)

print(f"number of faces: {len(faces)}")
facesNp = np.array(faces)
# Create the mesh
surface = mesh.Mesh(np.zeros(facesNp.shape[0], dtype=mesh.Mesh.dtype))
for i, f in enumerate(faces):
    for j in range(3):
        surface.vectors[i][j] = facesNp[i][j]
# Write the mesh to file "cube.stl"
surface.save('surface.stl')
print(surface)
[[248 248 248 ... 228 228 227]
 [249 248 248 ... 228 228 228]
 [249 248 249 ... 228 228 228]
 ...
 [ 62  60  62 ...  77  72  70]
 [ 53  56  61 ...  79  76  75]
 [ 53  59  61 ...  76  70  74]]
number of faces: 373252
<stl.mesh.Mesh object at 0x0000017D6C955F40>
a = np.zeros((3, 3))
a[:,0]=3
print(a[:,0])

print(a)
[3. 3. 3.]
[[3. 0. 0.]
 [3. 0. 0.]
 [3. 0. 0.]]
! pip install jupyter-cadquery==2.2.1 matplotlib
Collecting jupyter-cadquery==2.2.1
  Downloading jupyter_cadquery-2.2.1-py3-none-any.whl (175 kB)
Requirement already satisfied: matplotlib in c:\users\user\anaconda3\lib\site-packages (3.4.3)
Collecting sidecar~=0.5
  Downloading sidecar-0.5.1-py2.py3-none-any.whl (80 kB)
Collecting orbitcontrol-patch~=0.1.0
  Downloading orbitcontrol_patch-0.1.0-py2.py3-none-any.whl (2.1 MB)
Collecting cadquery-massembly~=0.9
  Downloading cadquery_massembly-0.9.0-py3-none-any.whl (5.9 kB)
Collecting pyquaternion~=0.9.9
  Downloading pyquaternion-0.9.9-py3-none-any.whl (14 kB)
Requirement already satisfied: notebook~=6.3 in c:\users\user\anaconda3\lib\site-packages (from jupyter-cadquery==2.2.1) (6.4.5)
Requirement already satisfied: webcolors~=1.11 in c:\users\user\anaconda3\lib\site-packages (from jupyter-cadquery==2.2.1) (1.11.1)
Collecting jupyter-cadquery-widgets~=2.0
  Downloading jupyter_cadquery_widgets-2.0.2-py3-none-any.whl (1.9 MB)
Requirement already satisfied: ipywidgets~=7.6 in c:\users\user\anaconda3\lib\site-packages (from jupyter-cadquery==2.2.1) (7.6.5)
Collecting pythreejs~=2.3
  Downloading pythreejs-2.3.0-py2.py3-none-any.whl (3.4 MB)
Collecting voila~=0.2
  Downloading voila-0.3.1-py3-none-any.whl (1.7 MB)
Requirement already satisfied: numpy>=1.16 in c:\users\user\anaconda3\lib\site-packages (from matplotlib) (1.20.3)
Requirement already satisfied: python-dateutil>=2.7 in c:\users\user\appdata\roaming\python\python39\site-packages (from matplotlib) (2.8.1)
Requirement already satisfied: kiwisolver>=1.0.1 in c:\users\user\anaconda3\lib\site-packages (from matplotlib) (1.3.1)
Requirement already satisfied: pyparsing>=2.2.1 in c:\users\user\anaconda3\lib\site-packages (from matplotlib) (3.0.4)
Requirement already satisfied: cycler>=0.10 in c:\users\user\anaconda3\lib\site-packages (from matplotlib) (0.10.0)
Requirement already satisfied: pillow>=6.2.0 in c:\users\user\anaconda3\lib\site-packages (from matplotlib) (8.4.0)
Requirement already satisfied: six in c:\users\user\appdata\roaming\python\python39\site-packages (from cycler>=0.10->matplotlib) (1.14.0)
Requirement already satisfied: traitlets>=4.3.1 in c:\users\user\anaconda3\lib\site-packages (from ipywidgets~=7.6->jupyter-cadquery==2.2.1) (5.1.1)
Requirement already satisfied: widgetsnbextension~=3.5.0 in c:\users\user\anaconda3\lib\site-packages (from ipywidgets~=7.6->jupyter-cadquery==2.2.1) (3.5.1)
Requirement already satisfied: nbformat>=4.2.0 in c:\users\user\anaconda3\lib\site-packages (from ipywidgets~=7.6->jupyter-cadquery==2.2.1) (5.1.3)
Requirement already satisfied: ipython>=4.0.0 in c:\users\user\anaconda3\lib\site-packages (from ipywidgets~=7.6->jupyter-cadquery==2.2.1) (7.29.0)
Requirement already satisfied: ipython-genutils~=0.2.0 in c:\users\user\appdata\roaming\python\python39\site-packages (from ipywidgets~=7.6->jupyter-cadquery==2.2.1) (0.2.0)
Requirement already satisfied: jupyterlab-widgets>=1.0.0 in c:\users\user\anaconda3\lib\site-packages (from ipywidgets~=7.6->jupyter-cadquery==2.2.1) (1.0.0)
Requirement already satisfied: ipykernel>=4.5.1 in c:\users\user\anaconda3\lib\site-packages (from ipywidgets~=7.6->jupyter-cadquery==2.2.1) (6.4.1)
Requirement already satisfied: jupyterlab~=3.0 in c:\users\user\anaconda3\lib\site-packages (from jupyter-cadquery-widgets~=2.0->jupyter-cadquery==2.2.1) (3.2.1)
Requirement already satisfied: jupyter-client>=5.3.4 in c:\users\user\anaconda3\lib\site-packages (from notebook~=6.3->jupyter-cadquery==2.2.1) (6.1.12)
Requirement already satisfied: Send2Trash>=1.5.0 in c:\users\user\anaconda3\lib\site-packages (from notebook~=6.3->jupyter-cadquery==2.2.1) (1.8.0)
Requirement already satisfied: nbconvert in c:\users\user\anaconda3\lib\site-packages (from notebook~=6.3->jupyter-cadquery==2.2.1) (6.1.0)
Requirement already satisfied: pyzmq>=17 in c:\users\user\anaconda3\lib\site-packages (from notebook~=6.3->jupyter-cadquery==2.2.1) (22.2.1)
Requirement already satisfied: prometheus-client in c:\users\user\anaconda3\lib\site-packages (from notebook~=6.3->jupyter-cadquery==2.2.1) (0.11.0)
Requirement already satisfied: terminado>=0.8.3 in c:\users\user\anaconda3\lib\site-packages (from notebook~=6.3->jupyter-cadquery==2.2.1) (0.9.4)
Requirement already satisfied: tornado>=6.1 in c:\users\user\anaconda3\lib\site-packages (from notebook~=6.3->jupyter-cadquery==2.2.1) (6.1)
Requirement already satisfied: jinja2 in c:\users\user\anaconda3\lib\site-packages (from notebook~=6.3->jupyter-cadquery==2.2.1) (2.11.3)
Requirement already satisfied: argon2-cffi in c:\users\user\anaconda3\lib\site-packages (from notebook~=6.3->jupyter-cadquery==2.2.1) (20.1.0)
Requirement already satisfied: jupyter-core>=4.6.1 in c:\users\user\appdata\roaming\python\python39\site-packages (from notebook~=6.3->jupyter-cadquery==2.2.1) (4.6.3)
Collecting ipydatawidgets>=1.1.1
  Downloading ipydatawidgets-4.2.0-py2.py3-none-any.whl (275 kB)
Requirement already satisfied: nbclient<0.6,>=0.4.0 in c:\users\user\anaconda3\lib\site-packages (from voila~=0.2->jupyter-cadquery==2.2.1) (0.5.3)
Requirement already satisfied: jupyter-server<2.0.0,>=0.3.0 in c:\users\user\anaconda3\lib\site-packages (from voila~=0.2->jupyter-cadquery==2.2.1) (1.4.1)
Collecting websockets>=9.0
  Downloading websockets-10.1-cp39-cp39-win_amd64.whl (97 kB)
Collecting traittypes>=0.2.0
  Downloading traittypes-0.2.1-py2.py3-none-any.whl (8.6 kB)
Requirement already satisfied: matplotlib-inline<0.2.0,>=0.1.0 in c:\users\user\anaconda3\lib\site-packages (from ipykernel>=4.5.1->ipywidgets~=7.6->jupyter-cadquery==2.2.1) (0.1.2)
Requirement already satisfied: debugpy<2.0,>=1.0.0 in c:\users\user\anaconda3\lib\site-packages (from ipykernel>=4.5.1->ipywidgets~=7.6->jupyter-cadquery==2.2.1) (1.4.1)
Requirement already satisfied: pickleshare in c:\users\user\appdata\roaming\python\python39\site-packages (from ipython>=4.0.0->ipywidgets~=7.6->jupyter-cadquery==2.2.1) (0.7.5)
Requirement already satisfied: pygments in c:\users\user\appdata\roaming\python\python39\site-packages (from ipython>=4.0.0->ipywidgets~=7.6->jupyter-cadquery==2.2.1) (2.5.2)
Requirement already satisfied: jedi>=0.16 in c:\users\user\appdata\roaming\python\python39\site-packages (from ipython>=4.0.0->ipywidgets~=7.6->jupyter-cadquery==2.2.1) (0.16.0)
Requirement already satisfied: setuptools>=18.5 in c:\users\user\anaconda3\lib\site-packages (from ipython>=4.0.0->ipywidgets~=7.6->jupyter-cadquery==2.2.1) (59.5.0)
Requirement already satisfied: decorator in c:\users\user\appdata\roaming\python\python39\site-packages (from ipython>=4.0.0->ipywidgets~=7.6->jupyter-cadquery==2.2.1) (4.4.2)
Requirement already satisfied: prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0 in c:\users\user\appdata\roaming\python\python39\site-packages (from ipython>=4.0.0->ipywidgets~=7.6->jupyter-cadquery==2.2.1) (3.0.3)
Requirement already satisfied: colorama in c:\users\user\appdata\roaming\python\python39\site-packages (from ipython>=4.0.0->ipywidgets~=7.6->jupyter-cadquery==2.2.1) (0.4.3)
Requirement already satisfied: backcall in c:\users\user\appdata\roaming\python\python39\site-packages (from ipython>=4.0.0->ipywidgets~=7.6->jupyter-cadquery==2.2.1) (0.1.0)
Requirement already satisfied: pywin32>=1.0 in c:\users\user\appdata\roaming\python\python39\site-packages (from jupyter-core>=4.6.1->notebook~=6.3->jupyter-cadquery==2.2.1) (227)
Requirement already satisfied: anyio>=2.0.2 in c:\users\user\anaconda3\lib\site-packages (from jupyter-server<2.0.0,>=0.3.0->voila~=0.2->jupyter-cadquery==2.2.1) (2.2.0)
Requirement already satisfied: jupyterlab-server~=2.3 in c:\users\user\anaconda3\lib\site-packages (from jupyterlab~=3.0->jupyter-cadquery-widgets~=2.0->jupyter-cadquery==2.2.1) (2.8.2)
Requirement already satisfied: nbclassic~=0.2 in c:\users\user\anaconda3\lib\site-packages (from jupyterlab~=3.0->jupyter-cadquery-widgets~=2.0->jupyter-cadquery==2.2.1) (0.2.6)
Requirement already satisfied: packaging in c:\users\user\anaconda3\lib\site-packages (from jupyterlab~=3.0->jupyter-cadquery-widgets~=2.0->jupyter-cadquery==2.2.1) (21.0)
Requirement already satisfied: MarkupSafe>=0.23 in c:\users\user\anaconda3\lib\site-packages (from jinja2->notebook~=6.3->jupyter-cadquery==2.2.1) (2.0.1)
Requirement already satisfied: async-generator in c:\users\user\anaconda3\lib\site-packages (from nbclient<0.6,>=0.4.0->voila~=0.2->jupyter-cadquery==2.2.1) (1.10)
Requirement already satisfied: nest-asyncio in c:\users\user\anaconda3\lib\site-packages (from nbclient<0.6,>=0.4.0->voila~=0.2->jupyter-cadquery==2.2.1) (1.5.1)
Requirement already satisfied: mistune<2,>=0.8.1 in c:\users\user\anaconda3\lib\site-packages (from nbconvert->notebook~=6.3->jupyter-cadquery==2.2.1) (0.8.4)
Requirement already satisfied: testpath in c:\users\user\anaconda3\lib\site-packages (from nbconvert->notebook~=6.3->jupyter-cadquery==2.2.1) (0.5.0)
Requirement already satisfied: defusedxml in c:\users\user\anaconda3\lib\site-packages (from nbconvert->notebook~=6.3->jupyter-cadquery==2.2.1) (0.7.1)
Requirement already satisfied: jupyterlab-pygments in c:\users\user\anaconda3\lib\site-packages (from nbconvert->notebook~=6.3->jupyter-cadquery==2.2.1) (0.1.2)
Requirement already satisfied: bleach in c:\users\user\anaconda3\lib\site-packages (from nbconvert->notebook~=6.3->jupyter-cadquery==2.2.1) (4.0.0)
Requirement already satisfied: pandocfilters>=1.4.1 in c:\users\user\anaconda3\lib\site-packages (from nbconvert->notebook~=6.3->jupyter-cadquery==2.2.1) (1.4.3)
Requirement already satisfied: entrypoints>=0.2.2 in c:\users\user\anaconda3\lib\site-packages (from nbconvert->notebook~=6.3->jupyter-cadquery==2.2.1) (0.3)
Requirement already satisfied: jsonschema!=2.5.0,>=2.4 in c:\users\user\anaconda3\lib\site-packages (from nbformat>=4.2.0->ipywidgets~=7.6->jupyter-cadquery==2.2.1) (3.2.0)
Requirement already satisfied: pywinpty>=0.5 in c:\users\user\anaconda3\lib\site-packages (from terminado>=0.8.3->notebook~=6.3->jupyter-cadquery==2.2.1) (0.5.7)
Requirement already satisfied: cffi>=1.0.0 in c:\users\user\anaconda3\lib\site-packages (from argon2-cffi->notebook~=6.3->jupyter-cadquery==2.2.1) (1.14.6)
Requirement already satisfied: sniffio>=1.1 in c:\users\user\anaconda3\lib\site-packages (from anyio>=2.0.2->jupyter-server<2.0.0,>=0.3.0->voila~=0.2->jupyter-cadquery==2.2.1) (1.2.0)
Requirement already satisfied: idna>=2.8 in c:\users\user\anaconda3\lib\site-packages (from anyio>=2.0.2->jupyter-server<2.0.0,>=0.3.0->voila~=0.2->jupyter-cadquery==2.2.1) (2.10)
Requirement already satisfied: pycparser in c:\users\user\anaconda3\lib\site-packages (from cffi>=1.0.0->argon2-cffi->notebook~=6.3->jupyter-cadquery==2.2.1) (2.20)
Requirement already satisfied: parso>=0.5.2 in c:\users\user\appdata\roaming\python\python39\site-packages (from jedi>=0.16->ipython>=4.0.0->ipywidgets~=7.6->jupyter-cadquery==2.2.1) (0.6.2)
Requirement already satisfied: pyrsistent>=0.14.0 in c:\users\user\anaconda3\lib\site-packages (from jsonschema!=2.5.0,>=2.4->nbformat>=4.2.0->ipywidgets~=7.6->jupyter-cadquery==2.2.1) (0.18.0)
Requirement already satisfied: attrs>=17.4.0 in c:\users\user\anaconda3\lib\site-packages (from jsonschema!=2.5.0,>=2.4->nbformat>=4.2.0->ipywidgets~=7.6->jupyter-cadquery==2.2.1) (21.2.0)
Requirement already satisfied: json5 in c:\users\user\anaconda3\lib\site-packages (from jupyterlab-server~=2.3->jupyterlab~=3.0->jupyter-cadquery-widgets~=2.0->jupyter-cadquery==2.2.1) (0.9.6)
Requirement already satisfied: babel in c:\users\user\anaconda3\lib\site-packages (from jupyterlab-server~=2.3->jupyterlab~=3.0->jupyter-cadquery-widgets~=2.0->jupyter-cadquery==2.2.1) (2.9.1)
Requirement already satisfied: requests in c:\users\user\anaconda3\lib\site-packages (from jupyterlab-server~=2.3->jupyterlab~=3.0->jupyter-cadquery-widgets~=2.0->jupyter-cadquery==2.2.1) (2.25.0)
Requirement already satisfied: wcwidth in c:\users\user\appdata\roaming\python\python39\site-packages (from prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0->ipython>=4.0.0->ipywidgets~=7.6->jupyter-cadquery==2.2.1) (0.1.8)
Requirement already satisfied: webencodings in c:\users\user\anaconda3\lib\site-packages (from bleach->nbconvert->notebook~=6.3->jupyter-cadquery==2.2.1) (0.5.1)
Requirement already satisfied: pytz>=2015.7 in c:\users\user\anaconda3\lib\site-packages (from babel->jupyterlab-server~=2.3->jupyterlab~=3.0->jupyter-cadquery-widgets~=2.0->jupyter-cadquery==2.2.1) (2021.3)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\user\anaconda3\lib\site-packages (from requests->jupyterlab-server~=2.3->jupyterlab~=3.0->jupyter-cadquery-widgets~=2.0->jupyter-cadquery==2.2.1) (2021.10.8)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\users\user\anaconda3\lib\site-packages (from requests->jupyterlab-server~=2.3->jupyterlab~=3.0->jupyter-cadquery-widgets~=2.0->jupyter-cadquery==2.2.1) (1.26.7)
Requirement already satisfied: chardet<4,>=3.0.2 in c:\users\user\anaconda3\lib\site-packages (from requests->jupyterlab-server~=2.3->jupyterlab~=3.0->jupyter-cadquery-widgets~=2.0->jupyter-cadquery==2.2.1) (3.0.4)
Installing collected packages: traittypes, websockets, ipydatawidgets, voila, sidecar, pythreejs, pyquaternion, orbitcontrol-patch, jupyter-cadquery-widgets, cadquery-massembly, jupyter-cadquery
Successfully installed cadquery-massembly-0.9.0 ipydatawidgets-4.2.0 jupyter-cadquery-2.2.1 jupyter-cadquery-widgets-2.0.2 orbitcontrol-patch-0.1.0 pyquaternion-0.9.9 pythreejs-2.3.0 sidecar-0.5.1 traittypes-0.2.1 voila-0.3.1 websockets-10.1
import cadquery as cq
import cadquery.freecad_impl as cadfc
import matplotlib.pyplot as plt
WARNING: CadQuery 1.x is no longer supported. Please upgrade to CadQuery 2.x https://github.com/CadQuery/cadquery
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
~\anaconda3\lib\site-packages\cadquery\freecad_impl\__init__.py in <module>
    151     try:
--> 152         import FreeCAD
    153     except ImportError:

ModuleNotFoundError: No module named 'FreeCAD'

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_12480/3928750954.py in <module>
      1 # run cadquery 2.2.1 example jupyter notebook
----> 2 import cadquery as cq
      3 import cadquery.freecad_impl as cadfc
      4 import matplotlib.pyplot as plt

~\anaconda3\lib\site-packages\cadquery\__init__.py in <module>
      4 
      5 #these items point to the freecad implementation
----> 6 from .freecad_impl.geom import Plane,BoundBox,Vector,Matrix,sortWiresByBuildOrder
      7 from .freecad_impl.shapes import Shape,Vertex,Edge,Face,Wire,Solid,Shell,Compound
      8 from .freecad_impl import exporters

~\anaconda3\lib\site-packages\cadquery\freecad_impl\__init__.py in <module>
    152         import FreeCAD
    153     except ImportError:
--> 154         path = _fc_path()
    155         sys.path.insert(0, path)
    156         import FreeCAD

~\anaconda3\lib\site-packages\cadquery\freecad_impl\__init__.py in _fc_path()
    144                 return _PATH
    145 
--> 146     raise ImportError('cadquery was unable to determine freecad library path')
    147 
    148 

ImportError: cadquery was unable to determine freecad library path
! pip install vpython
Collecting vpython
  Downloading vpython-7.6.3-cp39-cp39-win_amd64.whl (3.6 MB)
Requirement already satisfied: numpy in c:\users\user\anaconda3\lib\site-packages (from vpython) (1.20.3)
Requirement already satisfied: ipykernel in c:\users\user\anaconda3\lib\site-packages (from vpython) (6.4.1)
Collecting autobahn>=18.8.2
  Downloading autobahn-22.1.1.tar.gz (365 kB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
Requirement already satisfied: jupyter in c:\users\user\anaconda3\lib\site-packages (from vpython) (1.0.0)
Collecting jupyter-server-proxy
  Downloading jupyter_server_proxy-3.2.1-py3-none-any.whl (35 kB)
Collecting txaio>=21.2.1
  Using cached txaio-21.2.1-py2.py3-none-any.whl (30 kB)
Requirement already satisfied: cryptography>=3.4.6 in c:\users\user\anaconda3\lib\site-packages (from autobahn>=18.8.2->vpython) (3.4.8)
Requirement already satisfied: hyperlink>=21.0.0 in c:\users\user\anaconda3\lib\site-packages (from autobahn>=18.8.2->vpython) (21.0.0)
Requirement already satisfied: setuptools in c:\users\user\anaconda3\lib\site-packages (from autobahn>=18.8.2->vpython) (59.5.0)
Requirement already satisfied: debugpy<2.0,>=1.0.0 in c:\users\user\anaconda3\lib\site-packages (from ipykernel->vpython) (1.4.1)
Requirement already satisfied: ipython-genutils in c:\users\user\appdata\roaming\python\python39\site-packages (from ipykernel->vpython) (0.2.0)
Requirement already satisfied: ipython<8.0,>=7.23.1 in c:\users\user\anaconda3\lib\site-packages (from ipykernel->vpython) (7.29.0)
Requirement already satisfied: jupyter-client<8.0 in c:\users\user\anaconda3\lib\site-packages (from ipykernel->vpython) (6.1.12)
Requirement already satisfied: matplotlib-inline<0.2.0,>=0.1.0 in c:\users\user\anaconda3\lib\site-packages (from ipykernel->vpython) (0.1.2)
Requirement already satisfied: traitlets<6.0,>=4.1.0 in c:\users\user\anaconda3\lib\site-packages (from ipykernel->vpython) (5.1.1)
Requirement already satisfied: tornado<7.0,>=4.2 in c:\users\user\anaconda3\lib\site-packages (from ipykernel->vpython) (6.1)
Requirement already satisfied: qtconsole in c:\users\user\anaconda3\lib\site-packages (from jupyter->vpython) (5.1.1)
Requirement already satisfied: nbconvert in c:\users\user\anaconda3\lib\site-packages (from jupyter->vpython) (6.1.0)
Requirement already satisfied: ipywidgets in c:\users\user\anaconda3\lib\site-packages (from jupyter->vpython) (7.6.5)
Requirement already satisfied: jupyter-console in c:\users\user\anaconda3\lib\site-packages (from jupyter->vpython) (6.4.0)
Requirement already satisfied: notebook in c:\users\user\anaconda3\lib\site-packages (from jupyter->vpython) (6.4.5)
Requirement already satisfied: aiohttp in c:\users\user\anaconda3\lib\site-packages (from jupyter-server-proxy->vpython) (3.8.1)
Collecting simpervisor>=0.4
  Downloading simpervisor-0.4-py3-none-any.whl (5.7 kB)
Requirement already satisfied: jupyter-server>=1.0 in c:\users\user\anaconda3\lib\site-packages (from jupyter-server-proxy->vpython) (1.4.1)
Requirement already satisfied: cffi>=1.12 in c:\users\user\anaconda3\lib\site-packages (from cryptography>=3.4.6->autobahn>=18.8.2->vpython) (1.14.6)
Requirement already satisfied: idna>=2.5 in c:\users\user\anaconda3\lib\site-packages (from hyperlink>=21.0.0->autobahn>=18.8.2->vpython) (2.10)
Requirement already satisfied: prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0 in c:\users\user\appdata\roaming\python\python39\site-packages (from ipython<8.0,>=7.23.1->ipykernel->vpython) (3.0.3)
Requirement already satisfied: colorama in c:\users\user\appdata\roaming\python\python39\site-packages (from ipython<8.0,>=7.23.1->ipykernel->vpython) (0.4.3)
Requirement already satisfied: backcall in c:\users\user\appdata\roaming\python\python39\site-packages (from ipython<8.0,>=7.23.1->ipykernel->vpython) (0.1.0)
Requirement already satisfied: pickleshare in c:\users\user\appdata\roaming\python\python39\site-packages (from ipython<8.0,>=7.23.1->ipykernel->vpython) (0.7.5)
Requirement already satisfied: pygments in c:\users\user\appdata\roaming\python\python39\site-packages (from ipython<8.0,>=7.23.1->ipykernel->vpython) (2.5.2)
Requirement already satisfied: jedi>=0.16 in c:\users\user\appdata\roaming\python\python39\site-packages (from ipython<8.0,>=7.23.1->ipykernel->vpython) (0.16.0)
Requirement already satisfied: decorator in c:\users\user\appdata\roaming\python\python39\site-packages (from ipython<8.0,>=7.23.1->ipykernel->vpython) (4.4.2)
Requirement already satisfied: python-dateutil>=2.1 in c:\users\user\appdata\roaming\python\python39\site-packages (from jupyter-client<8.0->ipykernel->vpython) (2.8.1)
Requirement already satisfied: jupyter-core>=4.6.0 in c:\users\user\appdata\roaming\python\python39\site-packages (from jupyter-client<8.0->ipykernel->vpython) (4.6.3)
Requirement already satisfied: pyzmq>=13 in c:\users\user\anaconda3\lib\site-packages (from jupyter-client<8.0->ipykernel->vpython) (22.2.1)
Requirement already satisfied: nbformat in c:\users\user\anaconda3\lib\site-packages (from jupyter-server>=1.0->jupyter-server-proxy->vpython) (5.1.3)
Requirement already satisfied: terminado>=0.8.3 in c:\users\user\anaconda3\lib\site-packages (from jupyter-server>=1.0->jupyter-server-proxy->vpython) (0.9.4)
Requirement already satisfied: pywin32>=1.0 in c:\users\user\appdata\roaming\python\python39\site-packages (from jupyter-server>=1.0->jupyter-server-proxy->vpython) (227)
Requirement already satisfied: anyio>=2.0.2 in c:\users\user\anaconda3\lib\site-packages (from jupyter-server>=1.0->jupyter-server-proxy->vpython) (2.2.0)
Requirement already satisfied: Send2Trash in c:\users\user\anaconda3\lib\site-packages (from jupyter-server>=1.0->jupyter-server-proxy->vpython) (1.8.0)
Requirement already satisfied: prometheus-client in c:\users\user\anaconda3\lib\site-packages (from jupyter-server>=1.0->jupyter-server-proxy->vpython) (0.11.0)
Requirement already satisfied: jinja2 in c:\users\user\anaconda3\lib\site-packages (from jupyter-server>=1.0->jupyter-server-proxy->vpython) (2.11.3)
Requirement already satisfied: attrs>=17.3.0 in c:\users\user\anaconda3\lib\site-packages (from aiohttp->jupyter-server-proxy->vpython) (21.2.0)
Requirement already satisfied: aiosignal>=1.1.2 in c:\users\user\anaconda3\lib\site-packages (from aiohttp->jupyter-server-proxy->vpython) (1.2.0)
Requirement already satisfied: charset-normalizer<3.0,>=2.0 in c:\users\user\anaconda3\lib\site-packages (from aiohttp->jupyter-server-proxy->vpython) (2.0.4)
Requirement already satisfied: multidict<7.0,>=4.5 in c:\users\user\anaconda3\lib\site-packages (from aiohttp->jupyter-server-proxy->vpython) (5.2.0)
Requirement already satisfied: frozenlist>=1.1.1 in c:\users\user\anaconda3\lib\site-packages (from aiohttp->jupyter-server-proxy->vpython) (1.2.0)
Requirement already satisfied: yarl<2.0,>=1.0 in c:\users\user\anaconda3\lib\site-packages (from aiohttp->jupyter-server-proxy->vpython) (1.7.2)
Requirement already satisfied: async-timeout<5.0,>=4.0.0a3 in c:\users\user\anaconda3\lib\site-packages (from aiohttp->jupyter-server-proxy->vpython) (4.0.2)
Requirement already satisfied: jupyterlab-widgets>=1.0.0 in c:\users\user\anaconda3\lib\site-packages (from ipywidgets->jupyter->vpython) (1.0.0)
Requirement already satisfied: widgetsnbextension~=3.5.0 in c:\users\user\anaconda3\lib\site-packages (from ipywidgets->jupyter->vpython) (3.5.1)
Requirement already satisfied: jupyterlab-pygments in c:\users\user\anaconda3\lib\site-packages (from nbconvert->jupyter->vpython) (0.1.2)
Requirement already satisfied: nbclient<0.6.0,>=0.5.0 in c:\users\user\anaconda3\lib\site-packages (from nbconvert->jupyter->vpython) (0.5.3)
Requirement already satisfied: testpath in c:\users\user\anaconda3\lib\site-packages (from nbconvert->jupyter->vpython) (0.5.0)
Requirement already satisfied: entrypoints>=0.2.2 in c:\users\user\anaconda3\lib\site-packages (from nbconvert->jupyter->vpython) (0.3)
Requirement already satisfied: defusedxml in c:\users\user\anaconda3\lib\site-packages (from nbconvert->jupyter->vpython) (0.7.1)
Requirement already satisfied: mistune<2,>=0.8.1 in c:\users\user\anaconda3\lib\site-packages (from nbconvert->jupyter->vpython) (0.8.4)
Requirement already satisfied: pandocfilters>=1.4.1 in c:\users\user\anaconda3\lib\site-packages (from nbconvert->jupyter->vpython) (1.4.3)
Requirement already satisfied: bleach in c:\users\user\anaconda3\lib\site-packages (from nbconvert->jupyter->vpython) (4.0.0)
Requirement already satisfied: argon2-cffi in c:\users\user\anaconda3\lib\site-packages (from notebook->jupyter->vpython) (20.1.0)
Requirement already satisfied: qtpy in c:\users\user\anaconda3\lib\site-packages (from qtconsole->jupyter->vpython) (1.10.0)
Requirement already satisfied: sniffio>=1.1 in c:\users\user\anaconda3\lib\site-packages (from anyio>=2.0.2->jupyter-server>=1.0->jupyter-server-proxy->vpython) (1.2.0)
Requirement already satisfied: pycparser in c:\users\user\anaconda3\lib\site-packages (from cffi>=1.12->cryptography>=3.4.6->autobahn>=18.8.2->vpython) (2.20)
Requirement already satisfied: parso>=0.5.2 in c:\users\user\appdata\roaming\python\python39\site-packages (from jedi>=0.16->ipython<8.0,>=7.23.1->ipykernel->vpython) (0.6.2)
Requirement already satisfied: MarkupSafe>=0.23 in c:\users\user\anaconda3\lib\site-packages (from jinja2->jupyter-server>=1.0->jupyter-server-proxy->vpython) (2.0.1)
Requirement already satisfied: nest-asyncio in c:\users\user\anaconda3\lib\site-packages (from nbclient<0.6.0,>=0.5.0->nbconvert->jupyter->vpython) (1.5.1)
Requirement already satisfied: async-generator in c:\users\user\anaconda3\lib\site-packages (from nbclient<0.6.0,>=0.5.0->nbconvert->jupyter->vpython) (1.10)
Requirement already satisfied: jsonschema!=2.5.0,>=2.4 in c:\users\user\anaconda3\lib\site-packages (from nbformat->jupyter-server>=1.0->jupyter-server-proxy->vpython) (3.2.0)
Requirement already satisfied: wcwidth in c:\users\user\appdata\roaming\python\python39\site-packages (from prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0->ipython<8.0,>=7.23.1->ipykernel->vpython) (0.1.8)
Requirement already satisfied: six>=1.5 in c:\users\user\appdata\roaming\python\python39\site-packages (from python-dateutil>=2.1->jupyter-client<8.0->ipykernel->vpython) (1.14.0)
Requirement already satisfied: pywinpty>=0.5 in c:\users\user\anaconda3\lib\site-packages (from terminado>=0.8.3->jupyter-server>=1.0->jupyter-server-proxy->vpython) (0.5.7)
Requirement already satisfied: packaging in c:\users\user\anaconda3\lib\site-packages (from bleach->nbconvert->jupyter->vpython) (21.0)
Requirement already satisfied: webencodings in c:\users\user\anaconda3\lib\site-packages (from bleach->nbconvert->jupyter->vpython) (0.5.1)
Requirement already satisfied: pyrsistent>=0.14.0 in c:\users\user\anaconda3\lib\site-packages (from jsonschema!=2.5.0,>=2.4->nbformat->jupyter-server>=1.0->jupyter-server-proxy->vpython) (0.18.0)
Requirement already satisfied: pyparsing>=2.0.2 in c:\users\user\anaconda3\lib\site-packages (from packaging->bleach->nbconvert->jupyter->vpython) (3.0.4)
Building wheels for collected packages: autobahn
  Building wheel for autobahn (setup.py): started
  Building wheel for autobahn (setup.py): finished with status 'done'
  Created wheel for autobahn: filename=autobahn-22.1.1-cp39-cp39-win_amd64.whl size=506025 sha256=c9e3ac3eae448a97223038511944299ee02034c8e0444a716754a9dbee64f426
  Stored in directory: c:\users\user\appdata\local\pip\cache\wheels\26\73\3c\cff32de494c793a4ef83cd96838b70e9583f73a0bcaf329cc8
Successfully built autobahn
Installing collected packages: txaio, simpervisor, jupyter-server-proxy, autobahn, vpython
Successfully installed autobahn-22.1.1 jupyter-server-proxy-3.2.1 simpervisor-0.4 txaio-21.2.1 vpython-7.6.3
from vpython import *
sphere()
---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_12480/4280579786.py in <module>
      1 from vpython import *
----> 2 sphere()

~\anaconda3\lib\site-packages\vpython\vpython.py in __init__(self, **args)
   1151         args['_default_size'] = vector(2,2,2)
   1152         args['_objName'] = "sphere"
-> 1153         super(sphere, self).setup(args)
   1154         self._sizing = False # no axis/size connection
   1155 

~\anaconda3\lib\site-packages\vpython\vpython.py in setup(self, args)
    578 
    579     def setup(self, args):
--> 580         super(standardAttributes, self).__init__()
    581         self._constructing = True  ## calls to setters are from constructor
    582 

~\anaconda3\lib\site-packages\vpython\vpython.py in __init__(self, **kwargs)
    237                 baseObj._canvas_constructing):
    238             if _isnotebook:
--> 239                 from .with_notebook import _
    240             else:
    241                 from .no_notebook import _

~\anaconda3\lib\site-packages\vpython\with_notebook.py in <module>
    151 baseObj.glow = GlowWidget(wsport=__SOCKET_PORT, wsuri='/ws')
    152 while (not wsConnected):
--> 153     time.sleep(0.1)          # wait for websocket to connect
    154 
    155 baseObj.trigger()  # start the trigger ping-pong process

KeyboardInterrupt: 
from vpython import *
scene = canvas() # This is needed in Jupyter notebook and lab to make programs easily rerunnable
b = box(pos=vec(-4,2,0), color=color.red)
c1 = cylinder(pos=b.pos, radius=0.1, axis=vec(0,1.5,0), color=color.yellow)
s = sphere(pos=vec(4,-4,0), radius=0.5, color=color.green)
c2 = cylinder(pos=s.pos, radius=0.1, axis=vec(0,1.5,0), color=color.yellow)
t1 = text(text='box', pos=c1.pos+c1.axis, align='center', height=0.5,
          color=color.yellow, billboard=True, emissive=True)
t2 = text(text='sphere', pos=c2.pos+c2.axis, align='center', height=0.5,
          color=color.yellow, billboard=True, emissive=True)
t3 = text(text='Faces forward', pos=vec(-4,0,0),
          color=color.cyan, billboard=True, emissive=True)
box(pos=t3.start, size=0.1*vec(1,1,1), color=color.red)
t4 = text(text='Regular text', pos=vec(-4,-1,0), depth=0.5, color=color.yellow,
        start_face_color=color.red, end_face_color=color.green)
box(pos=t4.start, size=0.1*vec(1,1,1), color=color.red)

scene.caption = """<b>3D text can be "billboard" text -- always facing you.</b>
Note that the "Regular text" has different colors on the front, back and sides.
Right button drag or Ctrl-drag to rotate "camera" to view scene.
To zoom, drag with middle button or Alt/Option depressed, or use scroll wheel.
  On a two-button mouse, middle is left + right.
Touch screen: pinch/extend to zoom, swipe or two-finger rotate."""
---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_12480/3535009017.py in <module>
      1 from vpython import *
      2 scene = canvas() # This is needed in Jupyter notebook and lab to make programs easily rerunnable
----> 3 b = box(pos=vec(-4,2,0), color=color.red)
      4 c1 = cylinder(pos=b.pos, radius=0.1, axis=vec(0,1.5,0), color=color.yellow)
      5 s = sphere(pos=vec(4,-4,0), radius=0.5, color=color.green)

~\anaconda3\lib\site-packages\vpython\vpython.py in __init__(self, **args)
   1145         args['_default_size'] = vector(1,1,1)
   1146         args['_objName'] = "box"
-> 1147         super(box, self).setup(args)
   1148 
   1149 class sphere(standardAttributes):

~\anaconda3\lib\site-packages\vpython\vpython.py in setup(self, args)
    578 
    579     def setup(self, args):
--> 580         super(standardAttributes, self).__init__()
    581         self._constructing = True  ## calls to setters are from constructor
    582 

~\anaconda3\lib\site-packages\vpython\vpython.py in __init__(self, **kwargs)
    237                 baseObj._canvas_constructing):
    238             if _isnotebook:
--> 239                 from .with_notebook import _
    240             else:
    241                 from .no_notebook import _

~\anaconda3\lib\site-packages\vpython\with_notebook.py in <module>
    151 baseObj.glow = GlowWidget(wsport=__SOCKET_PORT, wsuri='/ws')
    152 while (not wsConnected):
--> 153     time.sleep(0.1)          # wait for websocket to connect
    154 
    155 baseObj.trigger()  # start the trigger ping-pong process

KeyboardInterrupt: 
psutil.sensors_battery()
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_12480/1724200509.py in <module>
----> 1 psutil.sensors_battery()

NameError: name 'psutil' is not defined