本文介绍了在无法访问互联网的情况下安装pythonnet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在无法访问互联网的计算机上安装pythonnet.在连接的计算机上,我从Github下载了pythonnet-master.zip,从pypi下载了pythonnet-2.4.0.tar.gz.

I am trying to install pythonnet on a machine with no internet access. On a connected machine I downloaded pythonnet-master.zip from Github, and pythonnet-2.4.0.tar.gz from pypi.

当我尝试 pip install pythonnet-2.4.0.tar.gz 时,出现错误远程名称无法解析:'www.nuget.org.

When I try pip install pythonnet-2.4.0.tar.gz, I get the error The remote name could not be resolved: 'www.nuget.org.

然后我使用 conda install nuget-3.2.0.10516-py34_0.tar.bz2 来处理nuget.安装成功,但是我仍然无法安装pythonnet.

I then used conda install nuget-3.2.0.10516-py34_0.tar.bz2 to take care of nuget. The installation was successful, but I still cannot install pythonnet.

我使用pythonnet-master.zip和 conda install 的尝试也失败了.任何想法都会有所帮助.

My attempts using pythonnet-master.zip and conda install also failed. Any ideas would be helpful.

这是完整的错误输出:

(raman_env) C:\Users\Administrator\Desktop\eric\software>pip install pythonnet-2
.4.0.tar.gz
Processing c:\users\administrator\desktop\eric\software\pythonnet-2.4.0.tar.gz
Building wheels for collected packages: pythonnet
  Building wheel for pythonnet (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: 'C:\ProgramData\Anaconda3\envs\raman_env\python.exe' -u -c 'import s
ys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\ADMINI~1\\AppData\\Local
\\Temp\\pip-req-build-8jks801m\\setup.py'"'"'; __file__='"'"'C:\\Users\\ADMINI~1
\\AppData\\Local\\Temp\\pip-req-build-8jks801m\\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 'C
:\Users\ADMINI~1\AppData\Local\Temp\pip-wheel-vi5w5zft' --python-tag cp37
       cwd: C:\Users\ADMINI~1\AppData\Local\Temp\pip-req-build-8jks801m\
  Complete output (44 lines):
  running bdist_wheel
  running build
  running build_ext
  Checking for updates from https://www.nuget.org/api/v2/.
  The remote name could not be resolved: 'www.nuget.org'
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "C:\Users\ADMINI~1\AppData\Local\Temp\pip-req-build-8jks801m\setup.py",
 line 658, in <module>
      zip_safe=False,
    File "C:\ProgramData\Anaconda3\envs\raman_env\lib\site-packages\setuptools\_
_init__.py", line 145, in setup
      return distutils.core.setup(**attrs)
    File "C:\ProgramData\Anaconda3\envs\raman_env\lib\distutils\core.py", line 1
48, in setup
      dist.run_commands()
    File "C:\ProgramData\Anaconda3\envs\raman_env\lib\distutils\dist.py", line 9
66, in run_commands
      self.run_command(cmd)
    File "C:\ProgramData\Anaconda3\envs\raman_env\lib\distutils\dist.py", line 9
85, in run_command
      cmd_obj.run()
    File "C:\Users\ADMINI~1\AppData\Local\Temp\pip-req-build-8jks801m\setup.py",
 line 610, in run
      return bdist_wheel.bdist_wheel.run(self)
    File "C:\ProgramData\Anaconda3\envs\raman_env\lib\site-packages\wheel\bdist_
wheel.py", line 192, in run
      self.run_command('build')
    File "C:\ProgramData\Anaconda3\envs\raman_env\lib\distutils\cmd.py", line 31
3, in run_command
      self.distribution.run_command(command)
    File "C:\ProgramData\Anaconda3\envs\raman_env\lib\distutils\dist.py", line 9
85, in run_command
      cmd_obj.run()
    File "C:\ProgramData\Anaconda3\envs\raman_env\lib\distutils\command\build.py
", line 135, in run
      self.run_command(cmd_name)
    File "C:\ProgramData\Anaconda3\envs\raman_env\lib\distutils\cmd.py", line 31
3, in run_command
      self.distribution.run_command(command)
    File "C:\ProgramData\Anaconda3\envs\raman_env\lib\distutils\dist.py", line 9
85, in run_command
      cmd_obj.run()
    File "C:\ProgramData\Anaconda3\envs\raman_env\lib\distutils\command\build_ex
t.py", line 340, in run
      self.build_extensions()
    File "C:\ProgramData\Anaconda3\envs\raman_env\lib\distutils\command\build_ex
t.py", line 449, in build_extensions
      self._build_extensions_serial()
    File "C:\ProgramData\Anaconda3\envs\raman_env\lib\distutils\command\build_ex
t.py", line 474, in _build_extensions_serial
      self.build_extension(ext)
    File "C:\Users\ADMINI~1\AppData\Local\Temp\pip-req-build-8jks801m\setup.py",
 line 245, in build_extension
      self._install_packages()
    File "C:\Users\ADMINI~1\AppData\Local\Temp\pip-req-build-8jks801m\setup.py",
 line 424, in _install_packages
      subprocess.check_call(cmd, shell=use_shell)
    File "C:\ProgramData\Anaconda3\envs\raman_env\lib\subprocess.py", line 347,
in check_call
      raise CalledProcessError(retcode, cmd)
  subprocess.CalledProcessError: Command 'tools\nuget\nuget.exe update -self' re
turned non-zero exit status 1.
  ----------------------------------------
  ERROR: 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
    ERROR: Command errored out with exit status 1:
     command: 'C:\ProgramData\Anaconda3\envs\raman_env\python.exe' -u -c 'import
 sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\ADMINI~1\\AppData\\Loc
al\\Temp\\pip-req-build-8jks801m\\setup.py'"'"'; __file__='"'"'C:\\Users\\ADMINI
~1\\AppData\\Local\\Temp\\pip-req-build-8jks801m\\setup.py'"'"';f=getattr(tokeni
ze, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\
n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --recor
d 'C:\Users\ADMINI~1\AppData\Local\Temp\pip-record-31isrm6o\install-record.txt'
--single-version-externally-managed --compile
         cwd: C:\Users\ADMINI~1\AppData\Local\Temp\pip-req-build-8jks801m\
    Complete output (6 lines):
    usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
       or: setup.py --help [cmd1 cmd2 ...]
       or: setup.py --help-commands
       or: setup.py cmd --help

    error: option --single-version-externally-managed not recognized
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\ProgramData\Anaconda3\envs\ra
man_env\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'
C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\pip-req-build-8jks801m\\setup.py'"'"'
; __file__='"'"'C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\pip-req-build-8jks801
m\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read
().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__,
'"'"'exec'"'"'))' install --record 'C:\Users\ADMINI~1\AppData\Local\Temp\pip-rec
ord-31isrm6o\install-record.txt' --single-version-externally-managed --compile C
heck the logs for full command output.

推荐答案

pythonnet setup.py 正在尝试运行 nugget.exe更新-自我,由于缺少互联网连接,因此在您的系统中失败.我可以想到两种可能的解决方案:

The setup.py of pythonnet is trying to run nugget.exe update --self which fails in you system because of the missing internet connection. I can think of two possible solutions:

  1. 请尝试下载正确的 whl 文件,而不是进行源安装.在pypi上,仅适用于cp37及以下版本.如果您运行的是pyhton 3.8,则可以在此处

  1. Instead of a source install, try to download the right whl file. On pypi, there are only ones for cp37 and below. If you are running pyhton 3.8, you can find the right wheel file here

提取tar.gz存档和注释行424: subprocess.check_call(cmd,shell = use_shell).然后运行 python setup.py install .这样可以防止安装程序在安装过程中尝试更新金块

Extract the tar.gz archive and comment line 424: subprocess.check_call(cmd, shell=use_shell). Then run python setup.py install. This will prevent setup from trying to update nugget during the installation process

这篇关于在无法访问互联网的情况下安装pythonnet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-05 09:54