5

Trying to install pythonnet 2.4.0 on Ubuntu 18.04 Bionic on Windows WSL, I get following error.

Mono version installed is 5.20.1.34 and 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

    ----------------------------------------
carraua
  • 1,398
  • 17
  • 36

3 Answers3

1

The problem was that I was using "pip" which referred to python2 pip, and should have been using pip3.

This fixed it for me:

$ sudo apt install python3-pip
$ pip3 install pythonnet==2.4.0
carraua
  • 1,398
  • 17
  • 36
0

This is mostly a duplicate of Pip Pythonnet option --single-version-externally-managed not recognized, just different platforms.

I answered the question there. The answer for me was to use an older, Python.NET-supported version of Python.

The current Python.NET supported versions should be listed @ http://pythonnet.github.io/.

Samuel
  • 8,063
  • 8
  • 45
  • 41
0

At my case I executed (installed wheel & setuptools before)

pip3 install pythonnet --verbose

and it seems like you have to execute

pip3 install pycparser

before you install pythonnet in some cases on Linux/mono; I think the installation process is quiet fragile and can mixed up the order so I recommend to install pycparser explicit before installing pythonnet

Furthermore running

pip3 install pythonnet --no-cache-dir

also failed on Linux/mono (my experience)

At the end it looks like this

pip3 install wheel
pip3 install setuptools
pip3 install pycparser
pip3 install pythonnet
Fluecke
  • 31
  • 4