Hi all! We have the following dependencies in our ...
# general
a
Hi all! We have the following dependencies in our project
Copy code
vtk==9.3.0
cadquery==2.4.0
Just importing those two in the same file:
Copy code
import cadquery
import vtk
Results in the following error:
Copy code
ImportError: Initialization failed for vtkWebCore, not compatible with vtkmodules.vtkCommonCore
This happens only when running with pants. Installing the libraries with
pip
and running the script works. Is there a way we can resolve that?
g
Can you provide the BUILD file source and pants.toml?
a
Here is the buildfile and pants.toml BUILD.pants
Copy code
python_sources()
g
What command are you running via pants that is throwing the python errors?
r
You are installing
vtk
but importing
vkt
? Is this just a typo here?
a
Yes, vtk - typo. I just run the script with imports as pants run demo.py
g
what is the output of these two commands?
Copy code
pants peek demo.py
pants dependencies --transitive demo.py
a
pants peek demo.py
pants dependencies --transitive demo.py
Also I got an answer from cadquery support: https://github.com/CadQuery/ocp-build-system/issues/23#issuecomment-1973326799 They suggest to use conda to workaround this, but since we use pants I believe it will not work.
@gentle-flower-25372 does it help? Is there anything else we can try?
đź‘€ 1
g
I just realized this isn't a blanket import error but some sort of internal library error. It also looks like you posted here that you found your answer?
a
The problem is not solved unfortunately. The reason I think it is a pants problem is that the error is not there when cadquery and vtk are installed with pip and I run them without pants. As soon as I run that same script with pants, the error appears. So the problem seems to be in how pants selects the vtk dependency. Does it make sense?
g
Are you using a virtualenv when not using pants?
I'd be interested to compare the difference between the two environments with
Copy code
python3 -m pip freeze --all
a
python3 -m pip freeze --all
g
a
yes
g
I don't know how to run
python3 -m pip freeze --all
from pants, but thats what I would try to do to compare them.
a
I think I managed. I exported a virtual environment and installed pip from the script.
vtk and cadquery versions are the same in both cases
g
@adamant-wolf-51914 I'd try creating a new virtualenv and use pip install --requirements with the output from pants and then test it out to see if the behavior is the same or different.
a
How will it help? From the freeze, the involved dependencies are exactly the same. I guess I could try to find out which version of vtkmodules.vtkCommonCore is imported exactly..
g
It wouldn’t solve the problem but it may give insight into why the problem is happening if you can reproduce outside of pants.