When installing SciPy 1.7.1 from source on Linux using
python setup.py build
python setup.py install
(along with environment and site.cfg
hacking as needed) I end up with a broken build. My particular build recipe works for SciPy <= 1.6
Once SciPy 1.7.1 is built, importing e.g. scipy.optimize
or scipy.special
results in errors
AttributeError: module 'scipy.special._ufuncs_cxx' has no attribute 'pyx_capi'
ImportError: cannot import name 'levinson' from 'scipy.linalg._solve_toeplitz'
ImportError: cannot import name 'csgraph_to_dense' from 'scipy.sparse.csgraph._tools'
What has changed, and how do I solve this?
Looking at the site-packages
directory I see that SciPy 1.7 installs itself as a zipped Python egg, whereas previous versions used to install as directories (though still Python eggs). This behaviour can be chosen by specifying the zip_safe
argument to setuptools.setup()
, called from within setup.py
. In SciPy 1.7 this is called as
setup(**metadata)
with metadata
not including 'zip_safe'
, meaning that whether zipped eggs are safe to use are automatically determined. This might also be the case for older SciPy versions, but for whatever reason the process ends up declaring zipped eggs to be safe for 1.7 on my system, which does not seem to be the case.
Manually adding
metadata['zip_safe'] = False
above setup(**metadata)
prior to executing setup.py
results in the egg being a directory (as opposed to a zipped archive), and the build works.
To do the patching of setup.py
programatically, use e.g. (GNU sed)
sed -i "s/\(^ *\)\(setup *(.*\)$/\1metadata['zip_safe'] = False; \2/" setup.py