installing Python module gives error

Answered

# I am running the following Python code in PyCharm, it gives error. The program
# and the error is show below.

# Program

from
evtk.hl import imageToVTK

import numpy as np

# Dimensions

nx, ny, nz = 6, 6, 2

ncells = nx * ny * nz

npoints = (nx + 1) * (ny + 1) * (nz + 1)

# Variables

pressure = np.random.rand(ncells).reshape( (nx, ny, nz), order = 'C')

temp = np.random.rand(npoints).reshape( (nx + 1, ny + 1, nz + 1))

imageToVTK("./image", cellData = {"pressure" : pressure}, pointData = {"temp" : temp} )

 

The following error is appeared,

 

C:\Anaconda3\python.exe C:/Users/Ali/PycharmProjects/project1/Test27.py
Traceback (most recent call last):
  File "C:/Users/Ali/PycharmProjects/project1/Test27.py", line 1, in <module>
    from evtk.hl import imageToVTK
ImportError: No module named 'evtk'
 
Process finished with exit code 1
 
My question is how can I install the package evtk.hl?
 
 
Iftikhar Ali
0
1 comment

Please see: https://www.jetbrains.com/help/pycharm/2016.3/installing-uninstalling-and-upgrading-packages.html.

But it seems that you meant PyEVTK package: https://pypi.python.org/pypi/PyEVTK/1.0.0.

You could change your first string to:

from pyevtk.hl import imageToVTK 

Then put your caret on highlighted `pyevtk`, press Alt+Enter and select "Install package pyevtk" option.

1

Please sign in to leave a comment.