【问题标题】:Erroneous SciPy 1.7 source build错误的 SciPy 1.7 源代码构建
【发布时间】:2021-10-19 19:20:14
【问题描述】:

在 Linux 上安装 SciPy 1.7.1 from source 时使用

python setup.py build
python setup.py install

(连同环境和site.cfg 黑客根据需要)我最终得到了一个损坏的构建。我的特定构建配方适用于 SciPy

一旦构建了 SciPy 1.7.1,导入例如scipy.optimizescipy.special 导致错误

AttributeError: 模块 'scipy.special._ufuncs_cxx' 没有属性 'pyx_capi'

ImportError: 无法从“scipy.linalg._solve_toeplitz”导入名称“levinson”

ImportError: 无法从“scipy.sparse.csgraph._tools”导入名称“csgraph_to_dense”

发生了什么变化,我该如何解决?

【问题讨论】:

    标签: python python-3.x linux scipy pythran


    【解决方案1】:

    查看site-packages 目录,我看到 SciPy 1.7 将自身安装为一个压缩的 Python 鸡蛋,而以前的版本用于安装为目录(尽管仍然是 Python 鸡蛋)。可以通过将zip_safe 参数指定为setuptools.setup() 来选择此行为,该参数从setup.py 中调用。在 SciPy 1.7 中,这是called as

    setup(**metadata)
    

    metadata 不包括'zip_safe',表示自动确定带拉链的鸡蛋是否可以安全使用。旧 SciPy 版本也可能是这种情况,但无论出于何种原因,该过程最终都会声明压缩鸡蛋在我的系统上对 1.7 是安全的,但似乎并非如此。

    手动添加

    metadata['zip_safe'] = False
    

    在执行setup.py 之前,在setup(**metadata) 之上会导致egg 成为一个目录(而不是压缩存档),并且构建工作正常。

    要以编程方式修补 setup.py,请使用例如(GNU sed)

    sed -i "s/\(^ *\)\(setup *(.*\)$/\1metadata['zip_safe'] = False; \2/" setup.py
    

    【讨论】:

    • 出于好奇,git submodule update --init && git clean -xdf && python3.9 -m pip install --user --upgrade --use-feature=in-tree-build . 这样的命令会产生什么结果?
    猜你喜欢
    • 2022-08-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多