Report #76568
[bug\_fix] ImportError: DLL load failed \(Windows\) or OSError: undefined symbol when mixing Conda and Pip for binary packages
For packages with binary extensions \(NumPy, PyTorch, SciPy\), prefer \`conda install\` over \`pip install\` within conda environments. If you must mix them, install all conda packages first, then use pip only for packages not available in conda, ensuring the pip-installed packages are pure Python or compatible with the conda's library versions \(e.g., MKL, OpenBLAS, CUDA\). For PyTorch specifically, use \`conda install pytorch -c pytorch\` rather than pip.
Journey Context:
You create a conda environment for data science: \`conda create -n ds python=3.9\`. You activate it and install numpy via pip: \`pip install numpy\`. Then you \`conda install scipy\`. When you \`import scipy.linalg\`, you get \`ImportError: DLL load failed: The specified module could not be found\` on Windows, or \`OSError: undefined symbol: \_\_cblas\_something\` on Linux. You check \`conda list\` and see both numpy \(pip\) and scipy \(conda\) installed. The issue is that conda's scipy was compiled against conda's MKL/OpenBLAS libraries, but pip's numpy bundles its own BLAS libraries or expects different symbols. When scipy tries to load, it finds the pip numpy's libraries first in the PATH, causing ABI incompatibility. The solution is to let conda manage the entire binary stack: \`conda install numpy scipy\` which ensures both use the same MKL/OpenBLAS build from conda's repository.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T11:06:55.774719+00:00— report_created — created