Skip to content

Find RDKit's Contrib directory on Windows - #3

Open
marc-lehner wants to merge 1 commit into
rdkit:mainfrom
knime-community:bug/windows-rdkit-contrib-path-upstream
Open

marc-lehner wants to merge 1 commit into
rdkit:mainfrom
knime-community:bug/windows-rdkit-contrib-path-upstream

Conversation

@marc-lehner

@marc-lehner marc-lehner commented Oct 26, 2026 •

Copy link
Copy Markdown

On Windows the extension loads no nodes. rdkit_descriptors.py imports SA_Score and NP_Score from RDKit's Contrib directory, which it expected under <prefix>/share/RDKit/Contrib. conda puts it there on Linux and macOS, but under <prefix>/Library/share/RDKit/Contrib on Windows. The import fails, and with it the whole extension:

Failed to load extension org.rdkit.python_rdkit_nodes from src with error: ...
  File ".../src/rdkit_descriptors.py", line 62, in <module>
    import SA_Score
ModuleNotFoundError: No module named 'SA_Score'

The fix tries both layouts relative to sys.exec_prefix, then RDConfig.RDContribDir, the documented way to reach Contrib (see rdkit/rdkit#2279). RDConfig stores the prefix from install time, so it is only the fallback for an environment that was moved; rdkit.Chem.Descriptors already imports it. On Linux and macOS the first path is the one used so far, so nothing changes there.

Verified on Windows (KNIME Analytics Platform 5.12, RDKit 2025.09.6 from conda-forge):

  • Without the fix, the extension's nodes are missing from the node repository and the error above is logged.
  • With the fix, all 3 nodes load (Calculate All Descriptors, Get Parent Molecule, Stereoisomer Enumeration). The descriptor function returns all 219 values for aspirin, including NP_Score, and SA_Score loads from Library\share\RDKit\Contrib.

The same commit is in the knime-community fork for the release lines: knime-community#9 (master), knime-community#10 (releases/5.13) and knime-community#11 (releases/5.12).

🤖 Generated with Claude Code

The descriptors node imports SA_Score and NP_Score from RDKit's Contrib
directory, which it expected under <prefix>/share/RDKit/Contrib. conda
installs it there on Linux and macOS, but under
<prefix>/Library/share/RDKit/Contrib on Windows. On Windows the import
failed, and with it the whole extension: KNIME showed none of its nodes.

Try both layouts relative to sys.exec_prefix, then RDConfig.RDContribDir.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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

Successfully merging this pull request may close these issues.

1 participant