Cython无法识别pymalloc Python

问题描述 投票:0回答:1

我有一个conda环境,使用Cython时会出现错误。我无法在不使错误消失的情况下减少依赖关系列表,所以这里是完整的环境:

# environment.yml
name: test
channels:
  - conda-forge
  - defaults
dependencies:
  - pip
  - compilers
  - make
  - setuptools
  - cython
  - daetk
  - hdf5 =*=*mpich*
  - h5py =*=*mpich*
  - metis
  - mpich
  - numpy
  - openblas
  - parmetis
  - petsc4py
  - petsc
  - python=3
  - scorec
  - superlu
  - superlu_dist
  - triangle
  - pychrono
  - mpi4py
  - gmsh
  - matplotlib
  - mpi4py
  - nose
  - pytables
  - pytest
  - pytest-cov
  - pytest-xdist
  - scipy
  - tetgen
  - ncurses
  - pychrono
  - python=3
  - future
  - ipyparallel
  - pillow
  - recordtype

使用:conda env create -f environment.yml创建环境

激活它:conda activate test

创建文件helloworld.pyx

print("Hello World")

创建setup.py

from distutils.core import setup
from Cython.Build import cythonize

setup(
    ext_modules = cythonize("helloworld.pyx")
)

Cyononize:python setup.py build_ext --inplace

[使用python -c "import helloworld"导入时,出现以下错误:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'helloworld'

它创建了一个文件helloworld.cpython-37-x86_64-linux-gnu.so,应该在其中helloworld.cpython-37m-x86_64-linux-gnu.so。的确,如果重命名它,您可以验证它是否可以正常工作:

mv helloworld.cpython-37-x86_64-linux-gnu.so helloworld.cpython-37m-x86_64-linux-gnu.so

并且在conda环境中,存在m后缀:$CONDA_PREFIX/include/python3.7m。我知道这与是否使用pymalloc编译Python有关,但是我不明白为什么Cython在这种情况下看不到它。

python cython distutils conda-forge
1个回答
0
投票

它实际上是由conda-forge中Python 3.7.6的错误构建引起的。已修复。

© www.soinside.com 2019 - 2024. All rights reserved.