当前位置:   article > 正文

python 虚拟环境迁移_python 虚拟环境能否移植到其他服务器吗

python 虚拟环境能否移植到其他服务器吗

今天需要把一个联网的服务器当中的python虚拟环境迁移到另外一个未联网的服务器当中。

简单分享一下今天遇到的问题。

通过conda-pack工具进行迁移。先安装:conda install conda-pack

问题:在过程中不小心升级了python 版本导致conda命令不可用;

方法:bash 原anconda3 安装包 -u

虚拟环境下conda install conda-pack:报错

# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<

    Traceback (most recent call last):
      File "/home/bonc/anaconda3/lib/python3.7/site-packages/conda/exceptions.py", line 819, in __call__
        return func(*args, **kwargs)
      File "/home/bonc/anaconda3/lib/python3.7/site-packages/conda/cli/main.py", line 78, in _main
        exit_code = do_call(args, p)
      File "/home/bonc/anaconda3/lib/python3.7/site-packages/conda/cli/conda_argparse.py", line 77, in do_call
        exit_code = getattr(module, func_name)(args, parser)
      File "/home/bonc/anaconda3/lib/python3.7/site-packages/conda/cli/main_install.py", line 11, in execute
        install(args, parser, 'install')
      File "/home/bonc/anaconda3/lib/python3.7/site-packages/conda/cli/install.py", line 235, in install
        force_reinstall=context.force,
      File "/home/bonc/anaconda3/lib/python3.7/site-packages/conda/core/solve.py", line 518, in solve_for_transaction
        force_remove, force_reinstall)
      File "/home/bonc/anaconda3/lib/python3.7/site-packages/conda/core/solve.py", line 451, in solve_for_diff
        final_precs = self.solve_final_state(deps_modifier, prune, ignore_pinned, force_remove)
      File "/home/bonc/anaconda3/lib/python3.7/site-packages/conda/core/solve.py", line 180, in solve_final_state
        index, r = self._prepare(prepared_specs)
      File "/home/bonc/anaconda3/lib/python3.7/site-packages/conda/core/solve.py", line 592, in _prepare
        self.subdirs, prepared_specs)
      File "/home/bonc/anaconda3/lib/python3.7/site-packages/conda/core/index.py", line 215, in get_reduced_index
        new_records = query_all(spec)
      File "/home/bonc/anaconda3/lib/python3.7/site-packages/conda/core/index.py", line 184, in query_all
        return tuple(concat(future.result() for future in as_completed(futures)))
      File "/home/bonc/anaconda3/lib/python3.7/site-packages/conda/core/subdir_data.py", line 95, in query
        self.load()
      File "/home/bonc/anaconda3/lib/python3.7/site-packages/conda/core/subdir_data.py", line 149, in load
        _internal_state = self._load()
      File "/home/bonc/anaconda3/lib/python3.7/site-packages/conda/core/subdir_data.py", line 218, in _load
        mod_etag_headers.get('_mod'))
      File "/home/bonc/anaconda3/lib/python3.7/site-packages/conda/core/subdir_data.py", line 280, in _read_local_repdata
        _internal_state = self._process_raw_repodata_str(raw_repodata_str)
      File "/home/bonc/anaconda3/lib/python3.7/site-packages/conda/core/subdir_data.py", line 317, in _process_raw_repodata_str
        json_obj = json.loads(raw_repodata_str or '{}')
      File "/home/bonc/anaconda3/lib/python3.7/json/__init__.py", line 348, in loads
        return _default_decoder.decode(s)
      File "/home/bonc/anaconda3/lib/python3.7/json/decoder.py", line 337, in decode
        obj, end = self.raw_decode(s, idx=_w(s, 0).end())
      File "/home/bonc/anaconda3/lib/python3.7/json/decoder.py", line 355, in raw_decode
        raise JSONDecodeError("Expecting value", s, err.value) from None
    json.decoder.JSONDecodeError: Expecting value: line 8041915 column 4 (char 244600832)

`$ /home/bonc/anaconda3/bin/conda install -c conda-forge conda-pack`

  environment variables:
                 CIO_TEST=<not set>
        CONDA_DEFAULT_ENV=bonc_ah_ss
                CONDA_EXE=/home/bonc/anaconda3/bin/conda
             CONDA_PREFIX=/home/bonc/anaconda3/envs/bonc_ah_ss
           CONDA_PREFIX_1=/home/bonc/anaconda3
    CONDA_PROMPT_MODIFIER=(bonc_ah_ss)
         CONDA_PYTHON_EXE=/home/bonc/anaconda3/bin/python
               CONDA_ROOT=/home/bonc/anaconda3
              CONDA_SHLVL=2
                     PATH=/home/bonc/anaconda3/envs/bonc_ah_ss/bin:/home/bonc/anaconda3/bin:/hom
                          e/bonc/anaconda3/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin
                          :/home/bonc/.local/bin:/home/bonc/bin
       REQUESTS_CA_BUNDLE=<not set>
            SSL_CERT_FILE=<not set>

     active environment : bonc_ah_ss
    active env location : /home/bonc/anaconda3/envs/bonc_ah_ss
            shell level : 2
       user config file : /home/bonc/.condarc
 populated config files :
          conda version : 4.5.11
    conda-build version : 3.15.1
         python version : 3.7.0.final.0
       base environment : /home/bonc/anaconda3  (writable)
           channel URLs : https://conda.anaconda.org/conda-forge/linux-64
                          https://conda.anaconda.org/conda-forge/noarch
                          https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/free/linux-64
                          https://repo.anaconda.com/pkgs/free/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
                          https://repo.anaconda.com/pkgs/pro/linux-64
                          https://repo.anaconda.com/pkgs/pro/noarch
          package cache : /home/bonc/anaconda3/pkgs
                          /home/bonc/.conda/pkgs
       envs directories : /home/bonc/anaconda3/envs
                          /home/bonc/.conda/envs
               platform : linux-64
             user-agent : conda/4.5.11 requests/2.19.1 CPython/3.7.0 Linux/3.10.0-1160.el7.x86_64 centos/7 glibc/2.17
                UID:GID : 1000:1000
             netrc file : None
           offline mode : False


An unexpected error has occurred. Conda has prepared the above report.
If submitted, this report will be used by core maintainers to improve
future releases of conda.
Would you like conda to send this report to the core maintainers?

pip install conda -pack,安装成功。

conda pack -n env_test

 打包成功!但运用实际情况当中,报错:咋办

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/180146
推荐阅读
相关标签
  

闽ICP备14008679号