Install pythonnet on Ubuntu 18.04, Python 3.6.7 64-bit, Mono 5.16 fails

≡放荡痞女 提交于 2020-01-01 19:46:05

问题


I would like to install pythonnet on Ubuntu, but it fails.

That's what I tried so far:

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

Error:

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('\r\n', '\n');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

I took a look as well at https://github.com/pythonnet/pythonnet/wiki/Installation but it didn't helped.

So this fails as well:

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

I tried as well with and without the --egg option.

By the way I'm behind a proxy server. So I tried as well to set the proxy server for NuGet, see NuGet Behind Proxy:

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

Any idea what I'm doing wrong?


回答1:


I was able to install it with the following commands:

sudo apt update
sudo apt-get install clang
sudo apt-get install libglib2.0-dev
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



回答2:


Change ownership of the file in question. I was having a similar with dotnet and what i did was to change the ownership of the file or folder.

sudo chown -R $user:$user /path_to_file


来源:https://stackoverflow.com/questions/55058757/install-pythonnet-on-ubuntu-18-04-python-3-6-7-64-bit-mono-5-16-fails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!