尝试在conda中脱机安装程序包时出现错误消息

时间:2017-03-29 20:47:05

标签: python anaconda conda

我有一台笔记本电脑无法连接到互联网,我有一个工作版本的Anaconda 3版本4.2。我还想安装PyVISA package

我下载了tar.bz2文件并将其复制到Anaconda3 / pkgs文件夹中。我导航到该目录并使用命令:

C:\Program Files\Anaconda3\pkgs>conda install --offline --use-local --use-index-cache pyvisa-1.8-py35_0.tar.bz2

我得到的回应是:

Extracting packages ...
An unexpected error has occurred.                                     |   0%
Please consider posting the following information to the
conda GitHub issue tracker at:

https://github.com/conda/conda/issues



Current conda install:

           platform : win-32
      conda version : 4.2.9
   conda is private : False
  conda-env version : 4.2.9
conda-build version : 2.0.2
     python version : 3.5.2.final.0
   requests version : 2.11.1
   root environment : C:\Program Files\Anaconda3  (read only)
default environment : C:\Program Files\Anaconda3
   envs directories : C:\Users\Name\.conda\envs
                      C:\Program Files\Anaconda3\envs
      package cache : C:\Users\Name\.conda\envs\.pkgs
                      C:\Program Files\Anaconda3\pkgs
       channel URLs : https://repo.continuum.io/pkgs/free/win-32/  (offline)

                      https://repo.continuum.io/pkgs/free/noarch/  (offline)

                      https://repo.continuum.io/pkgs/pro/win-32/  (offline)
                      https://repo.continuum.io/pkgs/pro/noarch/  (offline)
                      https://repo.continuum.io/pkgs/msys2/win-32/  (offline)
                      https://repo.continuum.io/pkgs/msys2/noarch/  (offline)
        config file : None
       offline mode : True

`$ C:\Program Files\Anaconda3\Scripts\conda-script.py install --offline --use-local --use-index-cache pyvisa-1.8-py35_0.tar.bz2`

Traceback (most recent call last):
  File "C:\Program Files\Anaconda3\lib\site-packages\conda\exceptions.py", l
ine 473, in conda_exception_handler
    return_value = func(*args, **kwargs)
  File "C:\Program Files\Anaconda3\lib\site-packages\conda\cli\main.py", lin
e 144, in _main
    exit_code = args.func(args, p)
  File "C:\Program Files\Anaconda3\lib\site-packages\conda\cli\main_install.
py", line 80, in execute
    install(args, parser, 'install')
  File "C:\Program Files\Anaconda3\lib\site-packages\conda\cli\install.py",
line 209, in install
    explicit(args.packages, prefix, verbose=not context.quiet)
  File "C:\Program Files\Anaconda3\lib\site-packages\conda\misc.py", line 18
7, in explicit
    execute_actions(actions, index=index, verbose=verbose)
  File "C:\Program Files\Anaconda3\lib\site-packages\conda\plan.py", line 64
3, in execute_actions
    inst.execute_instructions(plan, index, verbose)
  File "C:\Program Files\Anaconda3\lib\site-packages\conda\instructions.py",
line 134, in execute_instructions
    cmd(state, arg)
  File "C:\Program Files\Anaconda3\lib\site-packages\conda\instructions.py",
line 58, in EXTRACT_CMD
    extract(arg)
  File "C:\Program Files\Anaconda3\lib\site-packages\conda\install.py", line
792, in extract
    url = rec['urls'][0]
IndexError: list index out of range

从“列表索引超出范围”我发现它可能找不到文件,所以我使用了完整路径:

C:\Program Files\Anaconda3\pkgs>conda install --offline --use-local --use-index-cache C:\Program%20Files\Anaconda3\pkgs\pyvisa-1.8-py35_0.tar.bz2

我得到的回应是:

Traceback (most recent call last):
File "C:\Program Files\Anaconda3\lib\site-packages\conda\exceptions.py", line
473, in conda_exception_handler
return_value = func(*args, **kwargs)
File "C:\Program Files\Anaconda3\lib\site-packages\conda\cli\main.py", line 14
4, in _main
exit_code = args.func(args, p)
File "C:\Program Files\Anaconda3\lib\site-packages\conda\cli\main_install.py",
line 80, in execute
install(args, parser, 'install')
File "C:\Program Files\Anaconda3\lib\site-packages\conda\cli\install.py", line
209, in install
explicit(args.packages, prefix, verbose=not context.quiet)
File "C:\Program Files\Anaconda3\lib\site-packages\conda\misc.py", line 70, in
explicit
raise CondaFileNotFoundError(join(url_p, fn))
conda.exceptions.CondaFileNotFoundError: <exception str() failed>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Program Files\Anaconda3\Scripts\conda-script.py", line 5, in <module>

sys.exit(conda.cli.main())
File "C:\Program Files\Anaconda3\lib\site-packages\conda\cli\main.py", line 15
0, in main
return conda_exception_handler(_main)
File "C:\Program Files\Anaconda3\lib\site-packages\conda\exceptions.py", line
487, in conda_exception_handler
print_conda_exception(e)
File "C:\Program Files\Anaconda3\lib\site-packages\conda\exceptions.py", line
393, in print_conda_exception
stderrlogger.info(repr(exception))
File "C:\Program Files\Anaconda3\lib\site-packages\conda\__init__.py", line 42
, in __repr__
return '%s: %s\n' % (self.__class__.__name__, text_type(self))
File "C:\Program Files\Anaconda3\lib\site-packages\conda\__init__.py", line 45
, in __str__
return text_type(self.message % self._kwargs)
TypeError: a float is required

这里发生了什么?有没有办法离线安装此软件包?

更新1:

按照以下建议我试过

C:\Program Files\Anaconda3\pkgs>conda install --offline --use-local --use-index-cache --debug "C:\Program Files\Anaconda3\pkgs\pyvisa-1.8-py35_0.tar.bz2"

现在我得到了:

CondaValueError: Value error: invalid package specification

作为默认错误消息,如果我使用debug,则为以下内容:

DEBUG conda.models.channel:__init__(140): making channel object for url:https://repo.continuum.io/pkgs/free/win-32/alabaster-0.7.9-py35_0.tar.bz2
DEBUG conda.common.url:path_to_url(26): C:\Users\Name\conda-bld converted to file:///C:/Users/Name/conda-bld
DEBUG conda.models.channel:__init__(140): making channel object for url:file:///C:/Users/Name/conda-bld
DEBUG conda.models.channel:__init__(140): making channel object for url:https://repo.continuum.io/pkgs/free
DEBUG conda.models.channel:__init__(140): making channel object for url: https://repo.continuum.io/pkgs/pro
DEBUG conda.models.channel:__init__(140): making channel object for url: https://repo.continuum.io/pkgs/msys2
DEBUG conda.models.channel:__init__(140): making channel object for url: https://repo.continuum.io/pkgs/free/win-32/anaconda-4.2.0-np111py35_0.tar.bz2
DEBUG conda.models.channel:__init__(140): making channel object for url: https://repo.continuum.io/pkgs/free/win-32/anaconda-clean-1.0.0-py35_0.tar.bz2
DEBUG conda.models.channel:__init__(140): making channel object for url: https://repo.continuum.io/pkgs/free/win-32/anaconda-client-1.5.1-py35_0.tar.bz2
DEBUG conda.models.channel:__init__(140): making channel object for url: https://repo.continuum.io/pkgs/free/win-32/anaconda-navigator-1.3.1-py35_0.tar.bz2
DEBUG conda.models.channel:__init__(140): making channel object for url: https://repo.continuum.io/pkgs/free/win-32/argcomplete-1.0.0-py35_1.tar.bz2
DEBUG conda.models.channel:__init__(140): making channel object for url: https://repo.continuum.io/pkgs/free/win-32/astroid-1.4.7-py35_0.tar.bz2
DEBUG conda.models.channel:__init__(140): making channel object for url: https://repo.continuum.io/pkgs/free/win-32/astropy-1.2.1-np111py35_0.tar.bz2

等等,看起来像我的所有包裹,然后是

An unexpected error has occurred.
Please consider posting the following information to the
conda GitHub issue tracker at:

https://github.com/conda/conda/issues

INFO conda.common.io:captured(27): overtaking stderr and stdout
DEBUG conda.models.channel:__init__(161): making channel object for named channel: defaults
INFO conda.common.io:captured(33): stderr and stdout yielded back
Current conda install:

           platform : win-32
      conda version : 4.2.9
   conda is private : False
  conda-env version : 4.2.9
conda-build version : 2.0.2
     python version : 3.5.2.final.0
   requests version : 2.11.1
   root environment : C:\Program Files\Anaconda3  (read only)
default environment : C:\Program Files\Anaconda3
   envs directories : C:\Users\Name\.conda\envs
                      C:\Program Files\Anaconda3\envs
      package cache : C:\Users\Name\.conda\envs\.pkgs
                      C:\Program Files\Anaconda3\pkgs
       channel URLs : https://repo.continuum.io/pkgs/free/win-32/  (offline)

                      https://repo.continuum.io/pkgs/free/noarch/  (offline)

                      https://repo.continuum.io/pkgs/pro/win-32/  (offline)
                      https://repo.continuum.io/pkgs/pro/noarch/  (offline)
                      https://repo.continuum.io/pkgs/msys2/win-32/  (offline)
                      https://repo.continuum.io/pkgs/msys2/noarch/  (offline)
        config file : None
       offline mode : True



`$ C:\Program Files\Anaconda3\Scripts\conda-script.py install --offline --use-local --use-index-cache --debug C:\Program Files\Anaconda3\pkgs\pyvisa-1.8-py35_0.tar.bz2`




Traceback (most recent call last):
File "C:\Program Files\Anaconda3\lib\site-packages\conda\cli\common.py", line 466, in arg2spec
    spec = MatchSpec(spec_from_line(arg), normalize=True)
  File "C:\Program Files\Anaconda3\lib\site-packages\conda\resolve.py", line 43, in __new__
    spec, _, oparts = spec.partition('(')
AttributeError: 'NoneType' object has no attribute 'partition'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files\Anaconda3\lib\site-packages\conda\exceptions.py", line 473, in conda_exception_handler
    return_value = func(*args, **kwargs)
  File "C:\Program Files\Anaconda3\lib\site-packages\conda\cli\main.py", line 144, in _main
    exit_code = args.func(args, p)
  File "C:\Program Files\Anaconda3\lib\site-packages\conda\cli\main_install.py", line 80, in execute
    install(args, parser, 'install')
  File "C:\Program Files\Anaconda3\lib\site-packages\conda\cli\install.py",line 198, in install
    specs.extend(common.specs_from_args(args.packages, json=context.json))
  File "C:\Program Files\Anaconda3\lib\site-packages\conda\cli\common.py", line 483, in specs_from_args
    return [arg2spec(arg, json=json) for arg in args]
  File "C:\Program Files\Anaconda3\lib\site-packages\conda\cli\common.py", line 483, in <listcomp>
    return [arg2spec(arg, json=json) for arg in args]
  File "C:\Program Files\Anaconda3\lib\site-packages\conda\cli\common.py", line 468, in arg2spec
    raise CondaValueError('invalid package specification: %s' % arg)
conda.exceptions.CondaValueError: Value error: invalid package specification
: C:\Program Files\Anaconda3\pkgs\pyvisa-1.8-py35_0.tar.bz2

1 个答案:

答案 0 :(得分:1)

替换......

conda install --offline --use-local --use-index-cache C:\Program%20Files\Anaconda3\pkgs\pyvisa-1.8-py35_0.tar.bz2

... with:

conda install --offline --use-local --use-index-cache "C:\Program Files\Anaconda3\pkgs\pyvisa-1.8-py35_0.tar.bz2"

基本上,不要对绝对路径进行URI编码。