Pip Pythonnet 选项 --single-version-externally-managed 无法识别

Pip Pythonnet option --single-version-externally-managed not recognized

尝试在 Ubuntu 18.04 Bionic 上安装 pythonnet 2.4.0 在 Windows WSL 上,我收到以下错误。

安装的 Mono 版本是 5.20.1.34 和 Python 3.6

----------------------------------------
  Failed building wheel for pythonnet
  Running setup.py clean for pythonnet
Failed to build pythonnet
Installing collected packages: pythonnet
  Running setup.py install for pythonnet ... error
    Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-srixmeza/pythonnet/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-4wn8c3_a-record/install-record.txt --single-version-externally-managed --compile --user --prefix=:
    usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
       or: -c --help [cmd1 cmd2 ...]
       or: -c --help-commands
       or: -c cmd --help

    error: option --single-version-externally-managed not recognized

    ----------------------------------------

问题是我使用的 "pip" 指的是 python2 pip,应该使用 pip3。

这为我修复了它:

$ sudo apt install python3-pip
$ pip3 install pythonnet==2.4.0

这主要是 的重复,只是平台不同。

我在那里回答了问题。我的答案是使用较旧的 Python.NET 支持的 Python.

版本

应列出当前 Python.NET 支持的版本 @ http://pythonnet.github.io/

在我的案例中,我执行了(之前安装了 wheel 和 setuptools)

pip3 install pythonnet --verbose

看来你必须执行

pip3 install pycparser

在某些情况下 Linux/mono 安装 pythonnet 之前;我认为安装过程非常脆弱,可能会混淆顺序所以我建议在安装 pythonnet

之前显式安装 pycparser

此外运行

pip3 install pythonnet --no-cache-dir

Linux/mono 也失败了(我的经验)

最后看起来像这样

pip3 install wheel
pip3 install setuptools
pip3 install pycparser
pip3 install pythonnet