conda-forge / vtk-feedstock

A conda-smithy repository for vtk.
BSD 3-Clause "New" or "Revised" License
13 stars 64 forks source link

Windows conda-forge vtk 8.2 cannot import freetype #80

Closed flutefreak7 closed 1 year ago

flutefreak7 commented 5 years ago

On python 3.7 using miniconda, after conda install vtk installs conda-forge/win-64::vtk-8.2.0-py37h2bf1585_200 when I attempt python followed by import vtk I get the following traceback:

Traceback (most recent call last):
  File "C:\Miniconda3\lib\site-packages\vtkmodules\vtkRenderingFreeType.py", line 5, in <module>
    from .vtkRenderingFreeTypePython import *
ImportError: DLL load failed: The specified procedure could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Miniconda3\lib\site-packages\vtk.py", line 32, in <module>
    all_spec.loader.exec_module(all_m)
  File "C:\Miniconda3\lib\site-packages\vtkmodules\all.py", line 26, in <module>
    from .vtkRenderingFreeType import *
  File "C:\Miniconda3\lib\site-packages\vtkmodules\vtkRenderingFreeType.py", line 9, in <module>
    from vtkRenderingFreeTypePython import *
ModuleNotFoundError: No module named 'vtkRenderingFreeTypePython'

When I dug a little bit into the build logs I see that errors were encountered in the Windows builds of 8.2.

The only other place I see this error documented is here, related to mayavi. They mention different version of freetype being the issue and recommend installing from pip.

I have freetype 2.10.0 build h5db478b_0.

grlee77 commented 5 years ago

Can you report what version of freetype you have installed? (via conda list freetype)

grlee77 commented 5 years ago

sorry, I see you specified freetype 2.10.0 above. Is this a package from conda-forge or defaults?

It looks like the conda-forge pinning for freetype is currently 2.9.1 and that is what was used on the most recent Windows build (I think the Azure builds are still experimental on Windows and the Appveyor ones are the ones that get uploaded)

If you force 2.9.1 (conda install -c conda-forge "freetype==2.9.1"), does it work? Most likely we just need to enforce the pinning more tightly.

grlee77 commented 5 years ago

I opened conda-forge/freetype-feedstock#28 about potentially tightening the pinning enforced by freetype

isuruf commented 5 years ago

@flutefreak7 can you check if forcing freetype 2.9 fixes this issue? See https://github.com/conda-forge/vtk-feedstock/issues/80#issuecomment-479214153 for how

carlosantonio89 commented 5 years ago

Hi guys, I'm having the same problem described by @flutefreak7 . I tried to run the following code using freetype 2.9.1, vtk 8.2.0, python 3.7.3 with PyCharm 2019.1:

import sys
import vtk
from PyQt5 import QtCore, QtGui
from PyQt5 import Qt

from vtk.qt.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor

class MainWindow(Qt.QMainWindow):

    def __init__(self, parent = None):
        Qt.QMainWindow.__init__(self, parent)
        self.frame = Qt.QFrame()
        self.vl = Qt.QVBoxLayout()
        self.vtkWidget = QVTKRenderWindowInteractor(self.frame)
        self.vl.addWidget(self.vtkWidget)

        self.ren = vtk.vtkRenderer()
        self.vtkWidget.GetRenderWindow().AddRenderer(self.ren)
        self.iren = self.vtkWidget.GetRenderWindow().GetInteractor()

        # Create source
        source = vtk.vtkSphereSource()
        source.SetCenter(0, 0, 0)
        source.SetRadius(5.0)

        # Create a mapper
        mapper = vtk.vtkPolyDataMapper()
        mapper.SetInputConnection(source.GetOutputPort())

        # Create an actor
        actor = vtk.vtkActor()
        actor.SetMapper(mapper)

        self.ren.AddActor(actor)

        self.ren.ResetCamera()

        self.frame.setLayout(self.vl)
        self.setCentralWidget(self.frame)

        self.show()
        self.iren.Initialize()
        self.iren.Start()

if __name__ == "__main__":
    app = Qt.QApplication(sys.argv)
    window = MainWindow()
    sys.exit(app.exec_())

I have a fresh install of the latest Anaconda and Pycharm (64 bits). If I run this on Anaconda prompt, the code excutes fine without any error. But when I try it on Pycharm I have the following:

Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\lib\site-packages\vtkmodules\vtkRenderingFreeType.py", line 5, in <module>
    from .vtkRenderingFreeTypePython import *
ImportError: DLL load failed: The specified procedure could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/Dude/Desktop/main_window.py", line 9, in <module>
    import vtk
  File "C:\ProgramData\Anaconda3\lib\site-packages\vtk.py", line 32, in <module>
    all_spec.loader.exec_module(all_m)
  File "C:\ProgramData\Anaconda3\lib\site-packages\vtkmodules\all.py", line 26, in <module>
    from .vtkRenderingFreeType import *
  File "C:\ProgramData\Anaconda3\lib\site-packages\vtkmodules\vtkRenderingFreeType.py", line 9, in <module>
    from vtkRenderingFreeTypePython import *
ModuleNotFoundError: No module named 'vtkRenderingFreeTypePython'

I tried to solve this issue with the following link, but I didn't succeed.

https://youtrack.jetbrains.com/issue/PY-27234

I appreciate any help. Its been 5 days trying to solve this problem.

Thanks in advance.

isuruf commented 5 years ago

It's a pycharm issue that we cannot solve. A workaround is to start pycharm from an anaconda prompt.

carlosantonio89 commented 5 years ago

The problem persists even if I start PyCharm from anaconda prompt. Any other idea?

flutefreak7 commented 5 years ago

@flutefreak7 can you check if forcing freetype 2.9 fixes this issue? See #80 (comment) for how

I'm back... I attempting getting all my stuff working on conda again and hit this bug again. I attempted installing freetype=2.9 which did not appear to help.

I'm also seeing this in PyCharm, so I tried the PyCharm workaround involving calling pycharm from the anaconda prompt with my environment activated, but that didn't appear to help.

I have not attempted running my code outside PyCharm. I need to brush up on adding stuff to the python path so that my 4 libraries in parallel development can all import from each other.

amine-aboufirass commented 5 years ago

Also running into this problem. This implies the anaconda distribution of vtk does not work out of the box. In other terms, since most people who use python use anaconda as their main distribution environment, it kind of implies that vtk does not work at all....

The suggestion to install version 2.9.1 of freetype does not help at all.

grlee77 commented 5 years ago

@awa5114 Are you also using PyCharm when you have this issue?

If you try creating an environment where you install VTK via pip install vtkinstead of installing it via conda does it work? If the pip case fails in the same manner, then the issue is not with the conda-forge recipe itself.

EricAtORS commented 3 years ago

A colleague of mine had the same problem with this build: py37hf8bee71_203

After upgrading from pycharm 2019.1 to the current 2020.3.4, the issue is resolved.