Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"import vtk" fails after update to version 9 #14375

Closed
2 of 7 tasks
2manek opened this issue Dec 2, 2022 · 13 comments
Closed
2 of 7 tasks

"import vtk" fails after update to version 9 #14375

2manek opened this issue Dec 2, 2022 · 13 comments
Labels

Comments

@2manek
Copy link

2manek commented Dec 2, 2022

Description

after update vtk from version 8.2.0 to 9.2.2 I can not import vtk

>>> import vtk
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "E:/msys64.new/mingw64/lib/python3.10/site-packages/vtk.py", line 31, in <module>
    all_m = importlib.import_module('vtkmodules.all')
  File "E:/msys64.new/mingw64/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "E:/msys64.new/mingw64/lib/python3.10/site-packages/vtkmodules/all.py", line 7, in <module>
    from .vtkCommonCore import *
ModuleNotFoundError: No module named 'vtkmodules.vtkCommonCore'
$ python --version
Python 3.10.8

Verification

Windows Version

Microsoft Windows [Version 10.0.25252.1010]

MINGW environments affected

  • MINGW64
  • MINGW32
  • UCRT64
  • CLANG64
  • CLANG32
  • CLANGARM64

Expected behavior

import vtk with no errors

Actual behavior

vtk modules not found

Repro steps

  1. download current version of msys2
  2. update msys2 via pacman
  3. install mingw-w64-x86_64-python
  4. install mingw-w64-x86_64-vtk
  5. run python -c "import vtk"

Are you willing to submit a PR?

No response

@2manek 2manek added the bug label Dec 2, 2022
@MehdiChinoune
Copy link
Collaborator

Is python-matplotlib installed, if yes then try installing optional dependencies one by one and see which one fixes the issue.

@2manek
Copy link
Author

2manek commented Dec 2, 2022

I already have all optional vtk dependencies installed. I can't import vtk both when matplotlib is not installed and when it is installed.

I also checked the file /mingw64/lib/python3.10/site-packages/vtkmodules/vtkCommonCore.cpython-310.pyd with Dependency Walker and found no issues with missing DLLs.

@brisingraerowing
Copy link
Contributor

The VTK 9.2.2 python libraries have ',cpython310' bit, whereas the 8.x ones don't have anything of that sort. Try removing that from the file names and see if it imports. I have a feeling that's what's messing Python up.

@2manek
Copy link
Author

2manek commented Dec 7, 2022

It works, thank you! However, VTK seems to have missing functionality.
https://vtk.org/doc/nightly/html/classvtkExtractEdges.html

$ python
Python 3.10.8 (main, Nov  6 2022, 23:27:16)  [GCC 12.2.0 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from vtkmodules.vtkFiltersExtraction import vtkExtractEdges
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'vtkExtractEdges' from 'vtkmodules.vtkFiltersExtraction' (E:/msys64.curr.bak/mingw64/lib/python3.10/site-packages/vtkmodules/vtkFiltersExtraction.pyd)
>>> from vtkmodules import vtkFiltersExtraction
>>> dir(vtkFiltersExtraction)
[
  'VTK_EXTRACT_COMPONENT', 
  'VTK_EXTRACT_DETERMINANT', 
  'VTK_EXTRACT_EFFECTIVE_STRESS', 
  'VTK_EXTRACT_NONNEGATIVE_DETERMINANT', 
  'VTK_EXTRACT_TRACE', 
  '__doc__', 
  '__file__', 
  '__loader__', 
  '__name__', 
  '__package__', 
  '__spec__', 
  'vtkBlockSelector', 
  'vtkConvertSelection', 
  'vtkExpandMarkedElements', 
  'vtkExtractBlock', 
  'vtkExtractBlockUsingDataAssembly', 
  'vtkExtractCells', 
  'vtkExtractCellsByType', 
  'vtkExtractDataArraysOverTime', 
  'vtkExtractDataOverTime', 
  'vtkExtractDataSets', 
  'vtkExtractExodusGlobalTemporalVariables', 
  'vtkExtractGeometry', 
  'vtkExtractGrid', 
  'vtkExtractLevel', 
  'vtkExtractParticlesOverTime', 
  'vtkExtractPolyDataGeometry', 
  'vtkExtractRectilinearGrid', 
  'vtkExtractSelectedArraysOverTime', 
  'vtkExtractSelectedBlock', 
  'vtkExtractSelectedIds', 
  'vtkExtractSelectedLocations', 
  'vtkExtractSelectedPolyDataIds', 
  'vtkExtractSelectedRows', 
  'vtkExtractSelectedThresholds', 
  'vtkExtractSelection', 
  'vtkExtractTensorComponents', 
  'vtkExtractTimeSteps', 
  'vtkExtractUnstructuredGrid', 
  'vtkExtractVectorComponents', 
  'vtkFrustumSelector', 
  'vtkHierarchicalDataExtractDataSets', 
  'vtkHierarchicalDataExtractLevel', 
  'vtkLocationSelector', 
  'vtkProbeSelectedLocations', 
  'vtkSelector', 
  'vtkValueSelector'
]

@2manek
Copy link
Author

2manek commented Dec 7, 2022

OK, I see that vtkExtractEdges has been moved from vtkFiltersExtraction to vtkFiltersCore

@brisingraerowing
Copy link
Contributor

Good to know that it worked. That needs to be fixed.

@Biswa96
Copy link
Member

Biswa96 commented Dec 7, 2022

The VTK 9.2.2 python libraries have ',cpython310' bit

That is also true in Arch Linux, see

$ pacman -Fl vtk | grep -i "cpython-310-x86_64-linux-gnu.so" | head -n 5
vtk usr/lib/python3.10/site-packages/vtkmodules/vtkAcceleratorsVTKmCore.cpython-310-x86_64-linux-gnu.so
vtk usr/lib/python3.10/site-packages/vtkmodules/vtkAcceleratorsVTKmDataModel.cpython-310-x86_64-linux-gnu.so
vtk usr/lib/python3.10/site-packages/vtkmodules/vtkAcceleratorsVTKmFilters.cpython-310-x86_64-linux-gnu.so
vtk usr/lib/python3.10/site-packages/vtkmodules/vtkChartsCore.cpython-310-x86_64-linux-gnu.so
vtk usr/lib/python3.10/site-packages/vtkmodules/vtkCommonArchive.cpython-310-x86_64-linux-gnu.so

@2manek
Copy link
Author

2manek commented Dec 7, 2022

Yes, but on Linux it work fine, at least on my Manjaro with VTK 9.1.0

@2manek
Copy link
Author

2manek commented Dec 7, 2022

I think it should be called *.cp310-mingw_x86_64.pyd, but I haven't checked that yet.

@brisingraerowing
Copy link
Contributor

The Arch libs have the system triplet as well, and the MinGW ones don't. That being missing is probably throwing Python off.

@MehdiChinoune
Copy link
Collaborator

I think I have found the issue. VTK uses CMake Python3_SOABI as a default suffix, but CMake uses import sysconfig; sysconfig.get_config_var('SOABI') to get which gives a wrong value.

I think this issues should be fixed in mingw-w64-python

@MehdiChinoune
Copy link
Collaborator

@2manek Would you like to test packages built in #14476 (Checks -> arctifacts (right-corner)).

@MehdiChinoune
Copy link
Collaborator

Fixed by #14478

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants