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

Geom occ_utils imports V3d, AIS, Graphic3d, which are missing DLLs in Conda OCE #812

Closed
Moult opened this issue Mar 18, 2020 · 3 comments
Closed

Comments

@Moult
Copy link
Contributor

Moult commented Mar 18, 2020

The latest IfcOpenBot build e44221c has a little thing that breaks the BlenderBIM Add-on out of the box. This is the relevant history #736 and the PR that caused breakage This is the error:

Modules Installed (blenderbim) from 'C:\\Users\\moud308\\Downloads\\blender28-bim-200318-win.zip' into 'C:\\Users\\moud308\\AppData\\Roaming\\Blender Foundation\\Blender\\2.81\\scripts\\addons'
Traceback (most recent call last):
  File "C:\Users\moud308\AppData\Roaming\Blender Foundation\Blender\2.81\scripts\addons\ifcopenshell\geom\occ_utils.py", line 31, in <module>
    from OCC.Core import V3d, TopoDS, gp, AIS, Quantity, BRepTools, Graphic3d
ModuleNotFoundError: No module named 'OCC.Core'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\Blender Foundation\Blender 2.81\2.81\scripts\modules\addon_utils.py", line 351, in enable
    mod = __import__(module_name)
  File "C:\Users\moud308\AppData\Roaming\Blender Foundation\Blender\2.81\scripts\addons\blenderbim\__init__.py", line 31, in <module>
    from . import ui, prop, operator
  File "C:\Users\moud308\AppData\Roaming\Blender Foundation\Blender\2.81\scripts\addons\blenderbim\operator.py", line 8, in <module>
    from . import import_ifc
  File "C:\Users\moud308\AppData\Roaming\Blender Foundation\Blender\2.81\scripts\addons\blenderbim\import_ifc.py", line 2, in <module>
    import ifcopenshell.geom
  File "C:\Users\moud308\AppData\Roaming\Blender Foundation\Blender\2.81\scripts\addons\ifcopenshell\geom\__init__.py", line 43, in <module>
    from . import occ_utils as utils
  File "C:\Users\moud308\AppData\Roaming\Blender Foundation\Blender\2.81\scripts\addons\ifcopenshell\geom\occ_utils.py", line 33, in <module>
    from OCC import V3d, TopoDS, gp, AIS, Quantity, BRepTools, Graphic3d
  File "C:\Users\moud308\AppData\Roaming\Blender Foundation\Blender\2.81\scripts\addons\OCC\V3d.py", line 13, in <module>
    from . import _V3d
ImportError: DLL load failed: The specified module could not be found.

This is caused by geom/occ_utils.py L30:

try:
    from OCC.Core import V3d, TopoDS, gp, AIS, Quantity, BRepTools, Graphic3d
except ImportError:
    from OCC import V3d, TopoDS, gp, AIS, Quantity, BRepTools, Graphic3d

For some reason, the OCE builds I grab from Anaconda do not seem to contain the DLLs required on Windows (haven't tested Linux and MacOS) for the V3d module, AIS module, and Graphic3d module. For completeness, here are the builds I'm grabbing:

PYTHONOCC_URL:=https://anaconda.org/DLR-SC/pythonocc-core/0.17.3/download/win-64/pythonocc-core-0.17.3-py37he980bc4_10.tar.bz2
OCE_URL:=https://anaconda.org/DLR-SC/oce/0.17.2/download/win-64/oce-0.17.2-he980bc4_14.tar.bz2
TBB_URL:=https://anaconda.org/DLR-SC/tbb/2019.5/download/win-64/tbb-2019.5-he980bc4_0.tar.bz2

This error did not occur on previous builds, since previously those modules were lazy-loaded in their respective functions. E.g.:

def initialize_display():
    import OCC.V3d
    [ ... snip ... ]

A workaround for me is to patch the file to make it lazy-load the modules again (after all, I don't actually use the initialize_display etc functions). A better solution would be to find where those DLLs are ... but perhaps I'm just out of luck and Conda doesn't have them.

Thoughts?

@aothms
Copy link
Member

aothms commented Mar 20, 2020

Hm, so it's not about the .Core. part, it's just about making the modules now import at the beginning and somehow when you have downloaded the modules manually the runtime linker cannot find them?

I think it'd be good if you can check if you can reproduce this behaviour in a miniconda environment with dependencies properly installed through conda to see if it's related to the manual download or related to incompatibility between older oce packages and ifcopenshell.

Alternatively perhaps investigate if the latest builds from conda-forge work better. https://anaconda.org/conda-forge/pythonocc-core/files

Edit: one more thing, keep in mind that there are three layers of modules. The V3d.py generated by swig. The _V3d.pyd imported by the .py. And the TKV3d.dll from oce. The error seems to be related to the second item, which is still pythonocc-core and not oce.

Edit2: So that's ./Lib/site-packages/OCC/_V3d.pyd in the pythonocc-core archive

@Moult
Copy link
Contributor Author

Moult commented Aug 4, 2021

Closing as no longer relevant :)

@Moult Moult closed this as completed Aug 4, 2021
@Andrej730
Copy link
Contributor

Removing https://github.com/IfcOpenShell/IfcOpenShell/blob/v0.8.0/src/blenderbim/occ_utils.py:

  • we don't supply pythonocc with bbim anymore
  • tested that conda doesn't have that issue anymore and installing conda install -c conda-forge pythonocc-core provides all dll dependencies and it has no issues importing from OCC.Core import V3d

Andrej730 added a commit that referenced this issue Jul 16, 2024
Goodbye duplicated file 😁
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants