无法安装pyregion

Not able to install pyregion

我在 MacOS 中安装了 python 3.9。我不确定这是否是问题所在。我正在尝试为天文数据处理学校安装依赖项。所有软件包都已安装,但 pyregion 给出了这个巨大的错误。我怀疑 python 3.9 是否是问题所在。我不确定如何测试这在 python 3.7 中是否有效。如果我降级 python 会影响我已经安装的所有其他依赖项吗?

Pyregion 文档说支持 3.4 及更高版本。当我尝试安装 pyregion 时出现此错误:
不太确定这意味着什么以及如何解决它。

    ERROR: Command errored out with exit status 1:
     command: /Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9
 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = 
'"'"'/private/var/folders/01/z0gsg41x6_x8qm8qm6896b1m0000gn/T/pip-
install-_b4_sn3k/pyregion_bc69c141d64b4b48acd2e4f6d5160d9c/setup.py'"'"'; 
__file__='"'"'/private/var/folders/01/z0gsg41x6_x8qm8qm6896b1m0000g
n/T/pip-install-
_b4_sn3k/pyregion_bc69c141d64b4b48acd2e4f6d5160d9c/setup.py'"'"';f
 = getattr(tokenize, '"'"'open'"'"', open)(__file__) if 
os.path.exists(__file__) else io.StringIO('"'"'from setuptools 
import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"',
 '"'"'\n'"'"');f.close();exec(compile(code, __file__,
 '"'"'exec'"'"'))' install --record 
/private/var/folders/01/z0gsg41x6_x8qm8qm6896b1m0000gn/T/pip-
record-n_xc_qa3/install-record.txt --single-version-externally-
managed --compile --install-headers 
/Library/Frameworks/Python.framework/Versions/3.9/include/python3.9
/pyregion

         cwd: /private/var/folders/01/z0gsg41x6_x8qm8qm6896b1m0000gn/T/pip-install-_b4_sn3k/pyregion_bc69c141d64b4b48acd2e4f6d5160d9c/
    Complete output (120 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.9-x86_64-3.9
    creating build/lib.macosx-10.9-x86_64-3.9/pyregion
    copying pyregion/conftest.py -> build/lib.macosx-10.9-x86_64-3.9/pyregion
    copying pyregion/version.py -> build/lib.macosx-10.9-x86_64-3.9/pyregion
    copying pyregion/_astropy_init.py -> build/lib.macosx-10.9-x86_64-3.9/pyregion
    copying pyregion/region_numbers.py -> build/lib.macosx-10.9-x86_64-3.9/pyregion
    copying pyregion/region_to_filter.py -> build/lib.macosx-10.9-x86_64-3.9/pyregion
    copying pyregion/__init__.py -> build/lib.macosx-10.9-x86_64-3.9/pyregion
    copying pyregion/core.py -> build/lib.macosx-10.9-x86_64-3.9/pyregion
    copying pyregion/ds9_region_parser.py -> build/lib.macosx-10.9-x86_64-3.9/pyregion
    copying pyregion/parser_helper.py -> build/lib.macosx-10.9-x86_64-3.9/pyregion
    copying pyregion/cython_version.py -> build/lib.macosx-10.9-x86_64-3.9/pyregion
    copying pyregion/wcs_helper.py -> build/lib.macosx-10.9-x86_64-3.9/pyregion
    copying pyregion/mpl_helper.py -> build/lib.macosx-10.9-x86_64-3.9/pyregion
    copying pyregion/ds9_attr_parser.py -> build/lib.macosx-10.9-x86_64-3.9/pyregion
    copying pyregion/physical_coordinate.py -> build/lib.macosx-10.9-x86_64-3.9/pyregion
    copying pyregion/wcs_converter.py -> build/lib.macosx-10.9-x86_64-3.9/pyregion
    creating build/lib.macosx-10.9-x86_64-3.9/pyregion/tests
    copying pyregion/tests/test_ds9_attr_parser.py -> build/lib.macosx-10.9-x86_64-3.9/pyregion/tests
    copying pyregion/tests/__init__.py -> build/lib.macosx-10.9-x86_64-3.9/pyregion/tests
    copying pyregion/tests/test_cube.py -> build/lib.macosx-10.9-x86_64-3.9/pyregion/tests
    copying pyregion/tests/test_region_numbers.py -> build/lib.macosx-10.9-x86_64-3.9/pyregion/tests
    copying pyregion/tests/test_parser_helper.py -> build/lib.macosx-10.9-x86_64-3.9/pyregion/tests
    copying pyregion/tests/test_region.py -> build/lib.macosx-10.9-x86_64-3.9/pyregion/tests
    copying pyregion/tests/test_get_mask.py -> build/lib.macosx-10.9-x86_64-3.9/pyregion/tests
    copying pyregion/tests/test_wcs.py -> build/lib.macosx-10.9-x86_64-3.9/pyregion/tests
    copying pyregion/tests/setup_package.py -> build/lib.macosx-10.9-x86_64-3.9/pyregion/tests
    copying pyregion/tests/test_ds9_region_parser.py -> build/lib.macosx-10.9-x86_64-3.9/pyregion/tests
    copying pyregion/_region_filter.c -> build/lib.macosx-10.9-x86_64-3.9/pyregion
    copying pyregion/_compiler.c -> build/lib.macosx-10.9-x86_64-3.9/pyregion
    copying pyregion/tests/coveragerc -> build/lib.macosx-10.9-x86_64-3.9/pyregion/tests
    creating build/lib.macosx-10.9-x86_64-3.9/pyregion/tests/data
    copying pyregion/tests/data/test01_ds9_physical.reg -> build/lib.macosx-10.9-x86_64-3.9/pyregion/tests/data
    copying pyregion/tests/data/test_text.reg -> build/lib.macosx-10.9-x86_64-3.9/pyregion/tests/data
    copying pyregion/tests/data/test02_1_fk5.reg -> build/lib.macosx-10.9-x86_64-3.9/pyregion/tests/data
    copying pyregion/tests/data/test01_gal.reg -> build/lib.macosx-10.9-x86_64-3.9/pyregion/tests/data
    copying pyregion/tests/data/test_annuli.reg -> build/lib.macosx-10.9-x86_64-3.9/pyregion/tests/data
    copying pyregion/tests/data/test01_fk5_degree.reg -> build/lib.macosx-10.9-x86_64-3.9/pyregion/tests/data
    copying pyregion/tests/data/test01_img.reg -> build/lib.macosx-10.9-x86_64-3.9/pyregion/tests/data
    copying pyregion/tests/data/test01_ciao_physical.reg -> build/lib.macosx-10.9-x86_64-3.9/pyregion/tests/data
    copying pyregion/tests/data/test_annuli_wcs.reg -> build/lib.macosx-10.9-x86_64-3.9/pyregion/tests/data
    copying pyregion/tests/data/test03_img.reg -> build/lib.macosx-10.9-x86_64-3.9/pyregion/tests/data
    copying pyregion/tests/data/test_annuli_ciao.reg -> build/lib.macosx-10.9-x86_64-3.9/pyregion/tests/data
    copying pyregion/tests/data/test02.reg -> build/lib.macosx-10.9-x86_64-3.9/pyregion/tests/data
    copying pyregion/tests/data/test03_icrs.reg -> build/lib.macosx-10.9-x86_64-3.9/pyregion/tests/data
    copying pyregion/tests/data/test01.reg -> build/lib.macosx-10.9-x86_64-3.9/pyregion/tests/data
    copying pyregion/tests/data/test03_ciao_physical.reg -> build/lib.macosx-10.9-x86_64-3.9/pyregion/tests/data
    copying pyregion/tests/data/test03_gal.reg -> build/lib.macosx-10.9-x86_64-3.9/pyregion/tests/data
    copying pyregion/tests/data/test03_fk5.reg -> build/lib.macosx-10.9-x86_64-3.9/pyregion/tests/data
    copying pyregion/tests/data/test_context.reg -> build/lib.macosx-10.9-x86_64-3.9/pyregion/tests/data
    copying pyregion/tests/data/test02_1_img.reg -> build/lib.macosx-10.9-x86_64-3.9/pyregion/tests/data
    copying pyregion/tests/data/test04_img.reg -> build/lib.macosx-10.9-x86_64-3.9/pyregion/tests/data
    copying pyregion/tests/data/test01_fk5_sexagecimal.reg -> build/lib.macosx-10.9-x86_64-3.9/pyregion/tests/data
    copying pyregion/tests/data/test01_ciao.reg -> build/lib.macosx-10.9-x86_64-3.9/pyregion/tests/data
    copying pyregion/tests/data/test01_icrs.reg -> build/lib.macosx-10.9-x86_64-3.9/pyregion/tests/data
    copying pyregion/tests/data/test01_fk4.reg -> build/lib.macosx-10.9-x86_64-3.9/pyregion/tests/data
    copying pyregion/tests/data/test01_mixed.reg -> build/lib.macosx-10.9-x86_64-3.9/pyregion/tests/data
    copying pyregion/tests/data/test01_print.reg -> build/lib.macosx-10.9-x86_64-3.9/pyregion/tests/data
    copying pyregion/tests/data/test01_fk5.reg -> build/lib.macosx-10.9-x86_64-3.9/pyregion/tests/data
    copying pyregion/tests/data/sample_fits03.header -> build/lib.macosx-10.9-x86_64-3.9/pyregion/tests/data
    copying pyregion/tests/data/sample_fits01.header -> build/lib.macosx-10.9-x86_64-3.9/pyregion/tests/data
    copying pyregion/tests/data/test.header -> build/lib.macosx-10.9-x86_64-3.9/pyregion/tests/data
    copying pyregion/tests/data/sample_fits02.header -> build/lib.macosx-10.9-x86_64-3.9/pyregion/tests/data
    copying pyregion/tests/data/sample_fits04.header -> build/lib.macosx-10.9-x86_64-3.9/pyregion/tests/data
    running build_ext
    building 'pyregion._compiler' extension
    creating build/temp.macosx-10.9-x86_64-3.9
    creating build/temp.macosx-10.9-x86_64-3.9/pyregion
    gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -I/Library/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c pyregion/_compiler.c -o build/temp.macosx-10.9-x86_64-3.9/pyregion/_compiler.o
    gcc -bundle -undefined dynamic_lookup -arch x86_64 -g build/temp.macosx-10.9-x86_64-3.9/pyregion/_compiler.o -o build/lib.macosx-10.9-x86_64-3.9/pyregion/_compiler.cpython-39-darwin.so
    building 'pyregion._region_filter' extension
    gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -I/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/numpy/core/include -I/Library/Frameworks/Python.framework/Versions/3.9/include/python3.9 -c pyregion/_region_filter.c -o build/temp.macosx-10.9-x86_64-3.9/pyregion/_region_filter.o -Wp,-w -Wno-unused-function
    pyregion/_region_filter.c:11948:55: error: no member named 'tp_print' in 'struct _typeobject'
      __pyx_type_8pyregion_14_region_filter_RegionContext.tp_print = 0;
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    pyregion/_region_filter.c:11959:52: error: no member named 'tp_print' in 'struct _typeobject'
      __pyx_type_8pyregion_14_region_filter_RegionBase.tp_print = 0;
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    pyregion/_region_filter.c:11969:51: error: no member named 'tp_print' in 'struct _typeobject'
      __pyx_type_8pyregion_14_region_filter_RegionNot.tp_print = 0;
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    pyregion/_region_filter.c:11978:52: error: no member named 'tp_print' in 'struct _typeobject'
      __pyx_type_8pyregion_14_region_filter_RegionList.tp_print = 0;
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    pyregion/_region_filter.c:11988:54: error: no member named 'tp_print' in 'struct _typeobject'
      __pyx_type_8pyregion_14_region_filter_RegionOrList.tp_print = 0;
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    pyregion/_region_filter.c:11998:55: error: no member named 'tp_print' in 'struct _typeobject'
      __pyx_type_8pyregion_14_region_filter_RegionAndList.tp_print = 0;
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    pyregion/_region_filter.c:12009:51: error: no member named 'tp_print' in 'struct _typeobject'
      __pyx_type_8pyregion_14_region_filter_Transform.tp_print = 0;
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    pyregion/_region_filter.c:12019:49: error: no member named 'tp_print' in 'struct _typeobject'
      __pyx_type_8pyregion_14_region_filter_Rotated.tp_print = 0;
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    pyregion/_region_filter.c:12029:52: error: no member named 'tp_print' in 'struct _typeobject'
      __pyx_type_8pyregion_14_region_filter_Translated.tp_print = 0;
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    pyregion/_region_filter.c:12041:48: error: no member named 'tp_print' in 'struct _typeobject'
      __pyx_type_8pyregion_14_region_filter_Circle.tp_print = 0;
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    pyregion/_region_filter.c:12051:49: error: no member named 'tp_print' in 'struct _typeobject'
      __pyx_type_8pyregion_14_region_filter_Ellipse.tp_print = 0;
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    pyregion/_region_filter.c:12061:45: error: no member named 'tp_print' in 'struct _typeobject'
      __pyx_type_8pyregion_14_region_filter_Box.tp_print = 0;
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    pyregion/_region_filter.c:12071:49: error: no member named 'tp_print' in 'struct _typeobject'
      __pyx_type_8pyregion_14_region_filter_Polygon.tp_print = 0;
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    pyregion/_region_filter.c:12082:52: error: no member named 'tp_print' in 'struct _typeobject'
      __pyx_type_8pyregion_14_region_filter_AngleRange.tp_print = 0;
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
    14 errors generated.
    error: command '/usr/bin/gcc' failed with exit code 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: 
/Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9 -u -c 'import io, os, 
sys, setuptools, tokenize; sys.argv[0] = 
'"'"'/private/var/folders/01/z0gsg41x6_x8qm8qm6896b1m0000gn/T/pip-install-
_b4_sn3k/pyregion_bc69c141d64b4b48acd2e4f6d5160d9c/setup.py'"'"'; 
__file__='"'"'/private/var/folders/01/z0gsg41x6_x8qm8qm6896b1m0000gn/T/pip-install-
_b4_sn3k/pyregion_bc69c141d64b4b48acd2e4f6d5160d9c/setup.py'"'"';f = getattr(tokenize,
 '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from
 setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', 
'"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record
 /private/var/folders/01/z0gsg41x6_x8qm8qm6896b1m0000gn/T/pip-record-n_xc_qa3/install-
record.txt --single-version-externally-managed --compile --install-headers 
/Library/Frameworks/Python.framework/Versions/3.9/include/python3.9/pyregion Check the
 logs for full command output.

确实,pyregion 包似乎有一段时间没有更新了,其中包含一些与 Python 3.9 不兼容的 C 源代码。已有一个 issue 用于此。

似乎 github 中的最新版本至少可以工作:

pip install git+https://github.com/astropy/pyregion.git

您还需要 pip install pyerfa 因为它显然没有明确列为依赖项。

Indeed, it looks like the pyregion package has not been updated in some time, and contains some C sources that are not compatible with Python 3.9. There is an existing issue for this. It seems the latest version in github at least works: pip install git+https://github.com/astropy/pyregion.git You will also need to pip install pyerfa since it is apparently not explicitly listed as a dependency.

我试过了,但下载时遇到了更多问题。

ERROR: Command errored out with exit status 1:
     command: /home/cosmicmc/anaconda3/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-t3eybuyf/setup.py'"'"'; __file__='"'"'/tmp/pip-req-build-t3eybuyf/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-bb2m_uwy
         cwd: /tmp/pip-req-build-t3eybuyf/
    Complete output (5 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-req-build-t3eybuyf/setup.py", line 20, in <module>
        from astropy_helpers.setup_helpers import (register_commands, get_debug_option,
    ModuleNotFoundError: No module named 'astropy_helpers.setup_helpers'
    ----------------------------------------
WARNING: Discarding git+https://github.com/astropy/pyregion.git. Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

关于这个问题我应该问谁?