为 IronPython 安装 numpy

Install numpy for IronPython

我想 运行 使用 C# 在 IronPython 中编写一些代码。在这段代码中,我需要使用 numpy。所以我尝试使用以下命令安装它:

 ipy -X:Frames -m pip install -U numpy

不幸的是,我收到一条错误消息和一条 return 消息,告诉我安装不成功。错误信息如下:

Using cached https://files.pythonhosted.org/packages/3a/20/c81632328b1a4e1db65f45c0a1350a9c5341fd4bbb8ea66cdd98da56fe2e/numpy-1.15.0.zip
Installing collected packages: numpy
Running setup.py install for numpy ... error
Complete output from command "C:\Program Files\IronPython 2.7\ipy.exe" -u -c "import setuptools, tokenize;__file__='c:\users\mbhamida\appdata\local\temp\pip-build-t61kxu\numpy\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\mbhamida\appdata\local\temp\pip-y91bz0-record\install-record.txt --single-version-externally-managed --compile:
Running from numpy source directory.

Note: if you need reliable uninstall behavior, then install
with pip instead of using `setup.py install`:

  - `pip install .`       (from a git repo or downloaded source
                           release)
  - `pip install numpy`   (last NumPy release on PyPi)


C:\Program Files\IronPython 2.7\Lib\distutils\dist.py:1: UserWarning: Unknown distribution option: 'python_requires'
  """distutils.dist
blas_opt_info:
blas_mkl_info:
customize MSVCCompiler
  libraries mkl_rt not found in ['C:\Program Files\IronPython 2.7\lib']
  NOT AVAILABLE

blis_info:
customize MSVCCompiler
  libraries blis not found in ['C:\Program Files\IronPython 2.7\lib']
  NOT AVAILABLE

openblas_info:
customize MSVCCompiler
customize MSVCCompiler
  libraries openblas not found in ['C:\Program Files\IronPython 2.7\lib']
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "c:\users\mbhamida\appdata\local\temp\pip-build-t61kxu\numpy\setup.py", line 410, in <module>
  File "c:\users\mbhamida\appdata\local\temp\pip-build-t61kxu\numpy\numpy\distutils\core.py", line 135, in setup
  File "c:\users\mbhamida\appdata\local\temp\pip-build-t61kxu\numpy\numpy\distutils\system_info.py", line 625, in get_info
  File "c:\users\mbhamida\appdata\local\temp\pip-build-t61kxu\numpy\numpy\distutils\system_info.py", line 433, in get_info
  File "c:\users\mbhamida\appdata\local\temp\pip-build-t61kxu\numpy\numpy\distutils\system_info.py", line 625, in get_info
  File "c:\users\mbhamida\appdata\local\temp\pip-build-t61kxu\numpy\numpy\distutils\system_info.py", line 1758, in calc_info
  File "c:\users\mbhamida\appdata\local\temp\pip-build-t61kxu\numpy\numpy\distutils\fcompiler\__init__.py", line 61, in <module>
  File "c:\users\mbhamida\appdata\local\temp\pip-build-t61kxu\numpy\setup.py", line 402, in setup_package
  File "c:\users\mbhamida\appdata\local\temp\pip-build-t61kxu\numpy\setup.py", line 167, in configuration
  File "c:\users\mbhamida\appdata\local\temp\pip-build-t61kxu\numpy\numpy\distutils\misc_util.py", line 1032, in add_subpackage
  File "c:\users\mbhamida\appdata\local\temp\pip-build-t61kxu\numpy\numpy\distutils\misc_util.py", line 998, in get_subpackage
  File "c:\users\mbhamida\appdata\local\temp\pip-build-t61kxu\numpy\numpy\distutils\misc_util.py", line 940, in _get_configuration_from_setup_py
  File "numpy\setup.py", line 10, in configuration
  File "c:\users\mbhamida\appdata\local\temp\pip-build-t61kxu\numpy\numpy\distutils\misc_util.py", line 1032, in add_subpackage
  File "c:\users\mbhamida\appdata\local\temp\pip-build-t61kxu\numpy\numpy\distutils\misc_util.py", line 998, in get_subpackage
  File "c:\users\mbhamida\appdata\local\temp\pip-build-t61kxu\numpy\numpy\distutils\misc_util.py", line 940, in _get_configuration_from_setup_py
  File "numpy\core\setup.py", line 832, in configuration
  File "c:\users\mbhamida\appdata\local\temp\pip-build-t61kxu\numpy\numpy\distutils\system_info.py", line 433, in get_info
  File "c:\users\mbhamida\appdata\local\temp\pip-build-t61kxu\numpy\numpy\distutils\system_info.py", line 1621, in calc_info
TypeError: a new-style class can't have only classic bases

----------------------------------------
Command ""C:\Program Files\IronPython 2.7\ipy.exe" -u -c "import setuptools, tokenize;__file__='c:\users\mbhamida\appdata\local\temp\pip-build-t61kxu\numpy\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\mbhamida\appdata\local\temp\pip-y91bz0-record\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in c:\users\mbhamida\appdata\local\temp\pip-build-t61kxu\numpy\

我搜索了很多关于解决方案的信息,但我想这是一个非常普遍的问题。 Ps: 我在使用其他许多软件包时也遇到同样的问题。

有什么解决办法?

Python 首先是一种语言,在 C 中有一个默认实现:CPython。 IronPython 是该语言的另一种实现,基于 .NET。因此,它实现了默认的核心语言和大部分标准库。

一些通过 PIP 可用的 Python 包是纯 Python 并且依赖于 IronPython 支持的元素。然而,其他一些模块是特定于实现的。特别是,numpy 使用本机 C 代码,CPython 支持但 IronPython 不支持。有关 IronPython 问题跟踪器的更多信息:https://github.com/IronLanguages/ironpython2/issues/

要使其正常工作,numpy 必须提供与 .NET 的兼容性。我看过 numpy 的 .NET 重构,但从未让它工作。

您的问题有解决方案吗?避免混合使用 numpy 和 .NET。不过,如果您找到了让它发挥作用的方法,我很感兴趣。

[编辑:]您可能想看看这个关于如何安装 numpy 的答案: