# importing dataset\_adapter in PV 5.10

**URL:** https://discourse.paraview.org/t/importing-dataset-adapter-in-pv-5-10/8977
**Category:** ParaView Support
**Tags:** python
**Created:** [February 15, 2022, 10:15pm UTC](https://discourse.paraview.org/t/importing-dataset-adapter-in-pv-5-10/8977 "2022-02-15T22:15:11Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Andy\_Bauer](https://discourse.paraview.org/user_avatar/discourse.paraview.org/andy_bauer/32/5442_2.png) [@Andy\_Bauer](https://discourse.paraview.org/u/Andy_Bauer)
#### Post date: [February 15, 2022, 10:15pm UTC](https://discourse.paraview.org/t/importing-dataset-adapter-in-pv-5-10/8977/1 "2022-02-15T22:15:11Z")

</div>

I’m having trouble importing `dataset_adapter` in PV 5.10 using either `pvpython` or the `Python View` in the GUI. This is with the installer-based version. I’m not a Python expert but it seems like a bad idea to have a Python module with dashes in it, i.e. pv-vtk-all.py. What I’m seeing in `pvpython` is:

```auto
>>> from paraview.vtk import dataset_adapter as DA
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'dataset_adapter' from 'paraview.pv-vtk-all' (/home/acbauer/Code/ParaView/ParaView-5.10.0-MPI-Linux-Python3.9-x86_64/lib/python3.9/site-packages/paraview/pv-vtk-all.py)

```

Am I doing something wrong here or is this a bug? I’m going with the directions from  
[https://www.paraview.org/Wiki/Python\_Programmable\_Filter](https://www.paraview.org/Wiki/Python_Programmable_Filter)

Using the directions at [https://www.kitware.com/improved-vtk-numpy-integration-part-2/](https://www.kitware.com/improved-vtk-numpy-integration-part-2/) it imports like:

```auto
from vtk.numpy_interface import dataset_adapter as dsa

```

This seems to be the proper way to do it now.

Thanks,  
Andy

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cory.quammen/32/11193_2.png) [@cory.quammen](https://discourse.paraview.org/u/cory.quammen)
#### Post date: [February 16, 2022, 2:19pm UTC](https://discourse.paraview.org/t/importing-dataset-adapter-in-pv-5-10/8977/2 "2022-02-16T14:19:09Z")

</div>

> [@Andy\_Bauer](#):
>
> I’m not a Python expert but it seems like a bad idea to have a Python module with dashes in it, i.e. pv-vtk-all.py

Dashes are implicitly discouraged [in the PEP 8 guidelines](https://www.python.org/dev/peps/pep-0008/#package-and-module-names), but their presence is not the cause of your issue.

> [@Andy\_Bauer](#):
>
> Am I doing something wrong here or is this a bug? I’m going with the directions from  
> [https://www.paraview.org/Wiki/Python\_Programmable\_Filter](https://www.paraview.org/Wiki/Python_Programmable_Filter)

That example is incorrect. I fixed it to use `from paraview.vtk.numpy_interface import dataset_adapter as dsa`. The example was missing the `numpy_interface` module. Note that you can also write `from vtk.numpy_interface import dataset_adapter as dsa` - either works fine.

For more background on importing `vtk` vs. `paraview.vtk`, please see this [blog post](https://www.kitware.com/import-vtk-or-import-paraview-vtk/). Basically, if you want anything available in VTK, you can write

`import vtk`

This imports all of VTK, so it will be slow, hence doing so is discouraged.

If you only need a subset of VTK for commonly used filters, you can write `from paraview import vtk`. This is faster to import, but may not import all the VTK classes you need.

For ultimate efficiency, you can import only the VTK classes you absolutely need with statements like

`from vtkmodules.vtkFiltersCore import vtkSmoothPolyDataFilter`

The downside is you need to identify in which module a VTK class exists, but that isn’t too hard.
