Unable to import Viper

Asked by Aron Wahlberg

After upgrading to dolfin 0.9.7 plotting doesn't work.

>>> from dolfin import *
No module named vtk
*** Warning: Unable to import Viper, plotting disabled.
>>>
>>>
>>> import viper
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/aron/bzr/FEniCS/lib/python2.6/site-packages/viper/__init__.py", line 23, in <module>
    from viper import *
  File "/Users/aron/bzr/FEniCS/lib/python2.6/site-packages/viper/viper.py", line 48, in <module>
    import vtk, numpy, os, math
ImportError: No module named vtk

I have tried to reinstall vtk via macports but the problem remains.

Aron

Question information

Language:
English Edit question
Status:
Solved
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Solved by:
Aron Wahlberg
Solved:
Last query:
Last reply:
Revision history for this message
Aron Wahlberg (aron-simula) said :
#1

I still have the same problem.

I have reinstalled vtk:

sudo port uninstall vtk-devel
sudo port install vtk-devel +py26

and the rebuilt dolfin with dorsal.

I can't see why there is a problem now. Everything worked with my former version of dolfin (0.9.5).

Can I test vtk my installation of vtk in some other way? I get no warnings or anything while building it.
What file is being looked for when i type import vtk in a python shell? Can I somehow point this file out for my computer.
Anyone?

Revision history for this message
Johannes Ring (johannr) said :
#2

I'm also struggling with a Mac. Not with VTK though, but with MPI. Anyway, try to start Python and import VTK:

  fenicsslave2@buildbotmac:jhbuildbot$ python
  Python 2.6.4 (r264:75706, Feb 19 2010, 17:57:28)
  [GCC 4.2.1 (Apple Inc. build 5646) (dot 1)] on darwin
  Type "help", "copyright", "credits" or "license" for more information.
  >>> import vtk
  >>> vtk.__file__
  '/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/__init__.pyc'
  >>>

I'm using VTK from MacPorts and it works for me.

Revision history for this message
Johannes Ring (johannr) said :
#3

VTK also comes with a lot of examples. For instance you can try this:

  python /opt/local/share/vtk-5.4/examples/Tutorial/Step1/Python/Cone.py

Does this work for you? It doesn't seem like your problem has anything to do with DOLFIN.

Revision history for this message
Aron Wahlberg (aron-simula) said :
#4

Well, 'import vtk' just gives me the same old 'no module named vtk'.
However I did a 'locate vtk/__init__.pyc' which only gave me a reference to my Paraview directory.

In /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/ I have no vtk directory (!).

Running 'python /opt/local/share/vtk-5.4/examples/Tutorial/Step1/Python/Cone.py' also gives me 'no module named vtk'. :(

Appreciate your efforts!

Aron

Revision history for this message
Johannes Ring (johannr) said :
#5

What do you get from running this command:

  port contents vtk-devel | grep site-packages

?

Here is my output:

fenicsslave2@buildbotmac:~$ port contents vtk-devel | grep site-packages
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/__helper.py
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/__helper.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/__init__.py
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/__init__.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/common.py
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/common.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/filtering.py
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/filtering.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/genericfiltering.py
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/genericfiltering.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/geovis.py
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/geovis.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/graphics.py
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/graphics.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/gtk/__init__.py
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/gtk/__init__.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/gtk/GtkVTKRenderWindow.py
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/gtk/GtkVTKRenderWindow.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/gtk/GtkVTKRenderWindowInteractor.py
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/gtk/GtkVTKRenderWindowInteractor.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/hybrid.py
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/hybrid.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/imaging.py
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/imaging.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/infovis.py
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/infovis.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/io.py
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/io.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/libvtkCommonPython.so
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/libvtkFilteringPython.so
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/libvtkGenericFilteringPython.so
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/libvtkGeovisPython.so
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/libvtkGraphicsPython.so
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/libvtkHybridPython.so
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/libvtkImagingPython.so
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/libvtkInfovisPython.so
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/libvtkIOPython.so
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/libvtkParallelPython.so
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/libvtkRenderingPython.so
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/libvtkViewsPython.so
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/libvtkVolumeRenderingPython.so
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/libvtkWidgetsPython.so
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/parallel.py
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/parallel.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/qt/__init__.py
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/qt/__init__.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/qt/QVTKRenderWidget.py
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/qt/QVTKRenderWidget.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/qt/QVTKRenderWindowInteractor.py
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/qt/QVTKRenderWindowInteractor.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/qt4/__init__.py
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/qt4/__init__.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/qt4/QVTKRenderWindowInteractor.py
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/qt4/QVTKRenderWindowInteractor.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/rendering.py
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/rendering.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/required.py
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/required.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/test/__init__.py
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/test/__init__.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/test/BlackBox.py
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/test/BlackBox.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/test/Testing.py
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/test/Testing.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/tk/__init__.py
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/tk/__init__.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/tk/vtkLoadPythonTkWidgets.py
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/tk/vtkLoadPythonTkWidgets.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/tk/vtkTkImageViewerWidget.py
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/tk/vtkTkImageViewerWidget.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/tk/vtkTkPhotoImage.py
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/tk/vtkTkPhotoImage.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/tk/vtkTkRenderWidget.py
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/tk/vtkTkRenderWidget.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/tk/vtkTkRenderWindowInteractor.py
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/tk/vtkTkRenderWindowInteractor.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/util/__init__.py
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/util/__init__.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/util/colors.py
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/util/colors.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/util/misc.py
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/util/misc.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/util/numpy_support.py
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/util/numpy_support.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/util/vtkConstants.py
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/util/vtkConstants.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/util/vtkImageExportToArray.py
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/util/vtkImageExportToArray.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/util/vtkImageImportFromArray.py
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/util/vtkImageImportFromArray.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/util/vtkMethodParser.py
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/util/vtkMethodParser.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/views.py
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/views.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/volumerendering.py
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/volumerendering.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/widgets.py
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/widgets.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/wx/__init__.py
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/wx/__init__.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/wx/wxVTKRenderWindow.py
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/wx/wxVTKRenderWindow.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/wx/wxVTKRenderWindowInteractor.py
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk/wx/wxVTKRenderWindowInteractor.pyc
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/VTK-5.4.2-py2.6.egg-info/dependency_links.txt
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/VTK-5.4.2-py2.6.egg-info/not-zip-safe
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/VTK-5.4.2-py2.6.egg-info/PKG-INFO
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/VTK-5.4.2-py2.6.egg-info/SOURCES.txt
  /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/VTK-5.4.2-py2.6.egg-info/top_level.txt
fenicsslave2@buildbotmac:~$

Revision history for this message
Aron Wahlberg (aron-simula) said :
#6

I get nothing if I run that command. I have no directory /opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/vtk at all. Isn't that wierd!?

Revision history for this message
Johannes Ring (johannr) said :
#7

Yes, it seems to be something wrong with your VTK installation. You should try to reinstall like you did above but this time try to clean the build directory before installing:

  sudo port uninstall vtk-devel
  sudo port clean --all vtk-devel
  sudo port -v install vtk-devel +py26

Look for anything suspicious in the output.

Revision history for this message
Aron Wahlberg (aron-simula) said :
#8

I discovered that I had two port pythons of which only one was active. I uninstalled the older inactive port version of python. Then I did exactly what you suggest below, Johannes. I can't find anything peculiar or suspicious in the output but I still get the same error. I did have a few "not found" though. I don't know how alarming that is? I have made sure about 100 times that I run the mac port python and not the MacOSX one.

Aron

On 4 Mar, 2010, at 18:14, Johannes Ring wrote:

> Your question #102151 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/102151
>
> Johannes Ring posted a new comment:
> Yes, it seems to be something wrong with your VTK installation. You
> should try to reinstall like you did above but this time try to clean
> the build directory before installing:
>
> sudo port uninstall vtk-devel
> sudo port clean --all vtk-devel
> sudo port -v install vtk-devel +py26
>
> Look for anything suspicious in the output.
>

Revision history for this message
Aron Wahlberg (aron-simula) said :
#9

Do I have to manually put vtk on the pythonpath? In that case, what file/directory should go there?

Aron

On 4 Mar, 2010, at 18:14, Johannes Ring wrote:

> Your question #102151 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/102151
>
> Johannes Ring posted a new comment:
> Yes, it seems to be something wrong with your VTK installation. You
> should try to reinstall like you did above but this time try to clean
> the build directory before installing:
>
> sudo port uninstall vtk-devel
> sudo port clean --all vtk-devel
> sudo port -v install vtk-devel +py26
>
> Look for anything suspicious in the output.
>
> --
> You received this question notification because you are a direct
> subscriber of the question.

Revision history for this message
Aron Wahlberg (aron-simula) said :
#10

This problem is now solved. Instead of installing vtk-devel +py26 I installed vtk-devel + python26. I have no idea about the differences but it worked for me.

sudo port install vtk-devel +python26

was the magic key.

Aron

Revision history for this message
Harish Narayanan (hnarayanan) said :
#11

Thanks for pointing this out, I have made the change in the installation notes.

At some point, what was +py26 has become +python26. And for something like this in the future, you can do 'port variants package-name'