在Ubuntu 18.04上安装pythonnet,在Python 3.6.7 64位,Mono 5.16上安装失败

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在Ubuntu 18.04上安装pythonnet,在Python 3.6.7 64位,Mono 5.16上安装失败相关的知识,希望对你有一定的参考价值。

我想在Ubuntu上安装pythonnet,但它失败了。

那是我到目前为止所尝试的:

/usr/bin/python3 -m pip install -U pythonnet --user

错误:

Collection pythonnet
  Using cached https://files.pythonhosted.org/packages/89/3b/a22cd45b591d6cf490ee8b24d52b9db1f30b4b478b64a9b231c53474731e/pythonnet-2.3.0.tar.gz
Building wheels for collected packages: pythonnet
  Running setup.py bdist_wheel for pythonnet ... error
  Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-sv3ax85u/pythonnet/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('
', '
');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmp36arfp8upip-wheel- --python-tag cp36:
  running bdist_wheel
  running build
  running build_ext
  Checking for updates from https://www.nuget.org/api/v2/.
  Currently running NuGet.exe 3.5.0.
  Updating NuGet.exe to 4.9.3.
  Update successful.
  MSBuild auto-detection: using msbuild version '15.0' from '/usr/lib/mono/msbuild/15.0/bin'.
  Restoring NuGet package NUnit.3.6.0.
    GET https://api.nuget.org/v3-flatcontainer/nunit/3.6.0/nunit.3.6.0.nupkg
    OK https://api.nuget.org/v3-flatcontainer/nunit/3.6.0/nunit.3.6.0.nupkg 511ms
  Installing NUnit 3.6.0.
  WARNING: Error downloading 'NUnit.3.6.0' from 'https://api.nuget.org/v3-flatcontainer/nunit/3.6.0/nunit.3.6.0.nupkg'.
  Access to the path "/home/localadmin/.nuget/packages/nunit/3.6.0" is denied.
    GET https://api.nuget.org/v3-flatcontainer/nunit/3.6.0/nunit.3.6.0.nupkg
    OK https://api.nuget.org/v3-flatcontainer/nunit/3.6.0/nunit.3.6.0.nupkg 131ms
  Installing NUnit 3.6.0.
  WARNING: Error downloading 'NUnit.3.6.0' from 'https://api.nuget.org/v3-flatcontainer/nunit/3.6.0/nunit.3.6.0.nupkg'.
  Access to the path "/home/localadmin/.nuget/packages/nunit/3.6.0" is denied.
    GET https://api.nuget.org/v3-flatcontainer/nunit/3.6.0/nunit.3.6.0.nupkg
    OK https://api.nuget.org/v3-flatcontainer/nunit/3.6.0/nunit.3.6.0.nupkg 88ms
  Installing NUnit 3.6.0.
  WARNING: Unable to find version '3.6.0' of package 'NUnit'.
    /home/localadmin/.nuget/packages/: Package 'NUnit.3.6.0' is not found on source '/home/localadmin/.nuget/packages/'.
    https://api.nuget.org/v3/index.json: Error downloading 'NUnit.3.6.0' from 'https://api.nuget.org/v3-flatcontainer/nunit/3.6.0/nunit.3.6.0.nupkg'.
    Access to the path "/home/localadmin/.nuget/packages/nunit/3.6.0" is denied.

  Restoring NuGet package NUnit.ConsoleRunner.3.6.0.
    GET https://api.nuget.org/v3-flatcontainer/nunit.consolerunner/3.6.0/nunit.consolerunner.3.6.0.nupkg
    OK https://api.nuget.org/v3-flatcontainer/nunit.consolerunner/3.6.0/nunit.consolerunner.3.6.0.nupkg 503ms
  Installing NUnit.ConsoleRunner 3.6.0.
  WARNING: Error downloading 'NUnit.ConsoleRunner.3.6.0' from 'https://api.nuget.org/v3-flatcontainer/nunit.consolerunner/3.6.0/nunit.consolerunner.3.6.0.nupkg'.
  Access to the path "/home/localadmin/.nuget/packages/nunit.consolerunner/3.6.0" is denied.
    GET https://api.nuget.org/v3-flatcontainer/nunit.consolerunner/3.6.0/nunit.consolerunner.3.6.0.nupkg
    OK https://api.nuget.org/v3-flatcontainer/nunit.consolerunner/3.6.0/nunit.consolerunner.3.6.0.nupkg 1098ms
  Installing NUnit.ConsoleRunner 3.6.0.
  WARNING: Error downloading 'NUnit.ConsoleRunner.3.6.0' from 'https://api.nuget.org/v3-flatcontainer/nunit.consolerunner/3.6.0/nunit.consolerunner.3.6.0.nupkg'.
  Access to the path "/home/localadmin/.nuget/packages/nunit.consolerunner/3.6.0" is denied.
    GET https://api.nuget.org/v3-flatcontainer/nunit.consolerunner/3.6.0/nunit.consolerunner.3.6.0.nupkg
    OK https://api.nuget.org/v3-flatcontainer/nunit.consolerunner/3.6.0/nunit.consolerunner.3.6.0.nupkg 103ms
  Installing NUnit.ConsoleRunner 3.6.0.
  WARNING: Unable to find version '3.6.0' of package 'NUnit.ConsoleRunner'.
    /home/localadmin/.nuget/packages/: Package 'NUnit.ConsoleRunner.3.6.0' is not found on source '/home/localadmin/.nuget/packages/'.
    https://api.nuget.org/v3/index.json: Error downloading 'NUnit.ConsoleRunner.3.6.0' from 'https://api.nuget.org/v3-flatcontainer/nunit.consolerunner/3.6.0/nunit.consolerunner.3.6.0.nupkg'.
    Access to the path "/home/localadmin/.nuget/packages/nunit.consolerunner/3.6.0" is denied.

  Restoring NuGet package UnmanagedExports.1.2.7.
  WARNING: Unable to obtain lock file access on '/tmp/NuGetScratch/lock/db443dd345f7ac17ac9828f7824a62300ac88e2c' for operations on 'packages/UnmanagedExports.1.2.7'. This may mean that a different user or administator is holding this lock and that this process does not have permission to access it. If no other process is currently performing an operation on this file it may mean that an earlier NuGet process crashed and left an inaccessible lock file, in this case removing the file '/tmp/NuGetScratch/lock/db443dd345f7ac17ac9828f7824a62300ac88e2c' will allow NuGet to continue.
  WARNING: Error downloading 'NUnit.3.6.0' from 'https://api.nuget.org/v3-flatcontainer/nunit/3.6.0/nunit.3.6.0.nupkg'.
  Access to the path "/home/localadmin/.nuget/packages/nunit/3.6.0" is denied.
  WARNING: Error downloading 'NUnit.3.6.0' from 'https://api.nuget.org/v3-flatcontainer/nunit/3.6.0/nunit.3.6.0.nupkg'.
  Access to the path "/home/localadmin/.nuget/packages/nunit/3.6.0" is denied.
  WARNING: Unable to find version '3.6.0' of package 'NUnit'.
    /home/localadmin/.nuget/packages/: Package 'NUnit.3.6.0' is not found on source '/home/localadmin/.nuget/packages/'.
    https://api.nuget.org/v3/index.json: Error downloading 'NUnit.3.6.0' from 'https://api.nuget.org/v3-flatcontainer/nunit/3.6.0/nunit.3.6.0.nupkg'.
    Access to the path "/home/localadmin/.nuget/packages/nunit/3.6.0" is denied.

  WARNING: Error downloading 'NUnit.ConsoleRunner.3.6.0' from 'https://api.nuget.org/v3-flatcontainer/nunit.consolerunner/3.6.0/nunit.consolerunner.3.6.0.nupkg'.
  Access to the path "/home/localadmin/.nuget/packages/nunit.consolerunner/3.6.0" is denied.
  WARNING: Error downloading 'NUnit.ConsoleRunner.3.6.0' from 'https://api.nuget.org/v3-flatcontainer/nunit.consolerunner/3.6.0/nunit.consolerunner.3.6.0.nupkg'.
  Access to the path "/home/localadmin/.nuget/packages/nunit.consolerunner/3.6.0" is denied.
  WARNING: Unable to find version '3.6.0' of package 'NUnit.ConsoleRunner'.
    /home/localadmin/.nuget/packages/: Package 'NUnit.ConsoleRunner.3.6.0' is not found on source '/home/localadmin/.nuget/packages/'.
    https://api.nuget.org/v3/index.json: Error downloading 'NUnit.ConsoleRunner.3.6.0' from 'https://api.nuget.org/v3-flatcontainer/nunit.consolerunner/3.6.0/nunit.consolerunner.3.6.0.nupkg'.
    Access to the path "/home/localadmin/.nuget/packages/nunit.consolerunner/3.6.0" is denied.

  WARNING: Unable to obtain lock file access on '/tmp/NuGetScratch/lock/db443dd345f7ac17ac9828f7824a62300ac88e2c' for operations on 'packages/UnmanagedExports.1.2.7'. This may mean that a different user or administator is holding this lock and that this process does not have permission to access it. If no other process is currently performing an operation on this file it may mean that an earlier NuGet process crashed and left an inaccessible lock file, in this case removing the file '/tmp/NuGetScratch/lock/db443dd345f7ac17ac9828f7824a62300ac88e2c' will allow NuGet to continue.

  Errors in packages.config projects
      Unable to find version '3.6.0' of package 'NUnit'.
        /home/localadmin/.nuget/packages/: Package 'NUnit.3.6.0' is not found on source '/home/localadmin/.nuget/packages/'.
        https://api.nuget.org/v3/index.json: Error downloading 'NUnit.3.6.0' from 'https://api.nuget.org/v3-flatcontainer/nunit/3.6.0/nunit.3.6.0.nupkg'.
        Access to the path "/home/localadmin/.nuget/packages/nunit/3.6.0" is denied.
      Unable to find version '3.6.0' of package 'NUnit.ConsoleRunner'.
        /home/localadmin/.nuget/packages/: Package 'NUnit.ConsoleRunner.3.6.0' is not found on source '/home/localadmin/.nuget/packages/'.
        https://api.nuget.org/v3/index.json: Error downloading 'NUnit.ConsoleRunner.3.6.0' from 'https://api.nuget.org/v3-flatcontainer/nunit.consolerunner/3.6.0/nunit.consolerunner.3.6.0.nupkg'.
        Access to the path "/home/localadmin/.nuget/packages/nunit.consolerunner/3.6.0" is denied.
      Unable to obtain lock file access on '/tmp/NuGetScratch/lock/db443dd345f7ac17ac9828f7824a62300ac88e2c' for operations on 'packages/UnmanagedExports.1.2.7'. This may mean that a different user or administator is holding this lock and that this process does not have permission to access it. If no other process is currently performing an operation on this file it may mean that an earlier NuGet process crashed and left an inaccessible lock file, in this case removing the file '/tmp/NuGetScratch/lock/db443dd345f7ac17ac9828f7824a62300ac88e2c' will allow NuGet to continue.

  NuGet Config files used:
      /home/localadmin/.config/NuGet/NuGet.Config

  Feeds used:
      /home/localadmin/.nuget/packages/
      https://api.nuget.org/v3/index.json
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-build-sv3ax85u/pythonnet/setup.py", line 405, in <module>
      zip_safe=False,
    File "/home/localadmin/.local/lib/python3.6/site-packages/setuptools/__init__.py", line 145, in setup
      return distutils.core.setup(**attrs)
    File "/usr/lib/python3.6/distutils/core.py", line 148, in setup
      dist.run_commands()
    File "/usr/lib/python3.6/distutils/dist.py", line 955, in run_commands
      self.run_command(cmd)
    File "/usr/lib/python3.6/distutils/dist.py", line 974, in run_command
      cmd_obj.run()
    File "/usr/local/lib/python3.6/dist-packages/wheel/bdist_wheel.py", line 192, in run
      self.run_command('build')
    File "/usr/lib/python3.6/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/usr/lib/python3.6/distutils/dist.py", line 974, in run_command
      cmd_obj.run()
    File "/usr/lib/python3.6/distutils/command/build.py", line 135, in run
      self.run_command(cmd_name)
    File "/usr/lib/python3.6/distutils/cmd.py", line 313, in run_command
      self.distribution.run_command(command)
    File "/usr/lib/python3.6/distutils/dist.py", line 974, in run_command
      cmd_obj.run()
    File "/usr/lib/python3.6/distutils/command/build_ext.py", line 339, in run
      self.build_extensions()
    File "/usr/lib/python3.6/distutils/command/build_ext.py", line 448, in build_extensions
      self._build_extensions_serial()
    File "/usr/lib/python3.6/distutils/command/build_ext.py", line 473, in _build_extensions_serial
      self.build_extension(ext)
    File "/tmp/pip-build-sv3ax85u/pythonnet/setup.py", line 139, in build_extension
      self._install_packages()
    File "/tmp/pip-build-sv3ax85u/pythonnet/setup.py", line 273, in _install_packages
      subprocess.check_call(cmd, shell=use_shell)
    File "/usr/lib/python3.6/subprocess.py", line 291, in check_call
      raise CalledProcessError(retcode, cmd)
  subprocess.CalledProcessError: Command 'mono tools/nuget/nuget.exe restore pythonnet.sln -o packages' returned non-zero exit status 1.

  ----------------------------------------
  Failed building wheel for pythonnet

我在https://github.com/pythonnet/pythonnet/wiki/Installation看了一眼,但没有帮助。

所以这也失败了:

/usr/bin/python3 -m pip install git+https://github.com/pythonnet/pythonnet --user

无论有没有--egg选项,我都尝试过。

顺便说一句,我在代理服务器后面。所以我也尝试为NuGet设置代理服务器,请参阅NuGet Behind Proxy

mono /usr/lib/nuget/nuget.exe config -set http_proxy=http://my.proxy.address:port

知道我做错了什么吗?

答案

我能够使用以下命令安装它:

sudo apt-get install clang
sudo apt-get install libglib2.0-dev
sudo apt update
sudo apt install git
sudo apt install nuget
git config --global http.proxy http://my.proxy.address:port
mono /usr/lib/nuget/nuget.exe config -set http_proxy=http://my.proxy.address:port
/usr/bin/python3 -m pip install -U pycparser --user
/usr/bin/python3 -m pip install -U git+https://github.com/pythonnet/pythonnet --user --egg
另一答案

更改相关文件的所有权。我与dotnet类似,我所做的是更改文件或文件夹的所有权。

sudo chown -R $user:$user /path_to_file

以上是关于在Ubuntu 18.04上安装pythonnet,在Python 3.6.7 64位,Mono 5.16上安装失败的主要内容,如果未能解决你的问题,请参考以下文章

EOS 在ubuntu18.04上安装EOS

在 Ubuntu 18.04 上安装 RVM 时出错

我无法在 ubuntu 18.04 上安装 mysql

在 ubuntu 18.04 上安装 opencv 2.4.9

如何在虚拟机Ubuntu 18.04上安装catkin

在Ubuntu 18.04上安装Tensorflow