pyscf: image not found in Mac OS 2.0.0 install from PyPi.

In a fresh environment. I installed python -m pip install pyscf The .whl that was downloaded was pyscf-2.0.0-cp39-cp39-macosx_10_13_x86_64.whl It installed properly but when I tried to import pyscf.

Python 3.9.7 (default, Oct 13 2021, 06:45:31) 
[Clang 13.0.0 (clang-1300.0.29.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyscf
Traceback (most recent call last):
  File "/Users/jamesbrown/Documents/Coding/environments/pyscftest2/lib/python3.9/site-packages/pyscf/lib/misc.py", line 54, in load_library
    return numpy.ctypeslib.load_library(libname, _loaderpath)
  File "/Users/jamesbrown/Documents/Coding/environments/pyscftest2/lib/python3.9/site-packages/numpy/ctypeslib.py", line 149, in load_library
    return ctypes.cdll[libpath]
  File "/usr/local/Cellar/python@3.9/3.9.7_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ctypes/__init__.py", line 449, in __getitem__
    return getattr(self, name)
  File "/usr/local/Cellar/python@3.9/3.9.7_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ctypes/__init__.py", line 444, in __getattr__
    dll = self._dlltype(name)
  File "/usr/local/Cellar/python@3.9/3.9.7_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ctypes/__init__.py", line 374, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: dlopen(/Users/jamesbrown/Documents/Coding/environments/pyscftest2/lib/python3.9/site-packages/pyscf/lib/libcgto.dylib, 6): Library not loaded: @rpath/libcint.4.dylib
  Referenced from: /Users/jamesbrown/Documents/Coding/environments/pyscftest2/lib/python3.9/site-packages/pyscf/lib/libcgto.dylib
  Reason: image not found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/jamesbrown/Documents/Coding/environments/pyscftest2/lib/python3.9/site-packages/pyscf/__init__.py", line 114, in <module>
    from pyscf import gto
  File "/Users/jamesbrown/Documents/Coding/environments/pyscftest2/lib/python3.9/site-packages/pyscf/gto/__init__.py", line 19, in <module>
    from pyscf.gto import mole
  File "/Users/jamesbrown/Documents/Coding/environments/pyscftest2/lib/python3.9/site-packages/pyscf/gto/mole.py", line 46, in <module>
    from pyscf.gto import moleintor
  File "/Users/jamesbrown/Documents/Coding/environments/pyscftest2/lib/python3.9/site-packages/pyscf/gto/moleintor.py", line 29, in <module>
    libcgto = lib.load_library('libcgto')
  File "/Users/jamesbrown/Documents/Coding/environments/pyscftest2/lib/python3.9/site-packages/pyscf/lib/misc.py", line 62, in load_library
    return numpy.ctypeslib.load_library(libname, libpath)
  File "/Users/jamesbrown/Documents/Coding/environments/pyscftest2/lib/python3.9/site-packages/numpy/ctypeslib.py", line 149, in load_library
    return ctypes.cdll[libpath]
  File "/usr/local/Cellar/python@3.9/3.9.7_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ctypes/__init__.py", line 449, in __getitem__
    return getattr(self, name)
  File "/usr/local/Cellar/python@3.9/3.9.7_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ctypes/__init__.py", line 444, in __getattr__
    dll = self._dlltype(name)
  File "/usr/local/Cellar/python@3.9/3.9.7_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ctypes/__init__.py", line 374, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: dlopen(/Users/jamesbrown/Documents/Coding/environments/pyscftest2/lib/python3.9/site-packages/pyscf/lib/libcgto.dylib, 6): Library not loaded: @rpath/libcint.4.dylib
  Referenced from: /Users/jamesbrown/Documents/Coding/environments/pyscftest2/lib/python3.9/site-packages/pyscf/lib/libcgto.dylib
  Reason: image not found

When I go to /lib/python3.9/site-packages/pyscf/lib/libcgto.dylib and run

(pyscftest2) jamesbrown@MacBook Pro: jamesbrown lib % otool -l libcgto.dylib | grep libcint && otool -l libcgto.dylib | grep RPATH -A 2 
       name @rpath/libcint.4.dylib (offset 24)
        cmd LC_RPATH
    cmdsize 80
       path /Users/qssun/workspace/pyscf/pypi/pyscf-2.0/pyscf/lib/deps/lib (offset 12)
--
        cmd LC_RPATH
    cmdsize 80
       path /Users/qssun/workspace/pyscf/pypi/pyscf-2.0/pyscf/lib/deps/lib64 (offset 12)
--
        cmd LC_RPATH
    cmdsize 32
       path /usr/local/lib64 (offset 12)
--
        cmd LC_RPATH
    cmdsize 72
       path /Users/qssun/workspace/pyscf/pypi/pyscf-2.0/pyscf/lib (offset 12)

The installation works when I build from setup.py after cloning the git repository.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 24

Commits related to this issue

Most upvoted comments

Installing libcint and then pip installing from GitHub seems to do the trick on arm64. (I imagine that it would also work for x86 and rosetta) I don’t get any import errors for just pure pyscf code. But now it seems I must open an issue for some packages which use pyscf as a dependency. If anything I dig up there points back to pyscf, I will open a separate issue if it seems appropriate. Thank you for your help!

In next release, the source code and makefiles will be included in the sdist file on pypi.

The new wheel worked for me! I assume this issue can be closed now?

Installing libcint and then pip installing from GitHub seems to do the trick on arm64. (I imagine that it would also work for x86 and rosetta) I don’t get any import errors for just pure pyscf code. But now it seems I must open an issue for some packages which use pyscf as a dependency. If anything I dig up there points back to pyscf, I will open a separate issue if it seems appropriate. Thank you for your help!