使用环境中的conda中的PIP升级到最新版本。

发布于 2025-01-18 11:13:16 字数 967 浏览 0 评论 0原文

我正在尝试使用 environment.yaml 创建一个环境,由于某种原因,conda 在我的环境中安装的默认 pip 需要很长时间来处理依赖项。

因此,我试图以某种方式升级 conda 环境文件中的 pip 版本。

name: temp_env
channels:
  - pytorch
  - defaults
dependencies:
  - python=3.7
  - pytorch::pytorch=1.11.0
  - pytorch::torchvision=0.12.0
  - pytorch::cpuonly
  - pip
  - pip: 
      - -e '.[dev]'

此安装附带的 pip 版本是 pip 21.2.2 。我正在尝试将 pip 升级到最新版本,目前为 22.0.4。我可以编写一个 bash 脚本来先安装没有 pip 部分的 conda 环境,然后在其中安装包,但这不太理想。我正在尝试仅使用 YAML 文件提出解决方案。

我尝试了这个:

  - pip>=22.0.4
  - pip: 
      - -e '.[dev]'

但显然这个版本在 conda 的主要频道上还不存在。我也尝试过:

  - pip
  - pip:
    - -U pip
    - -e '.[dev]'

但这也不起作用并引发错误。

['/path/to/miniconda3/envs/temp_env/bin/python', '-m', 'pip', '安装', '-U', '-r', '/path/to/文件夹/condaenv.0kdmzdvh.requirements.txt']

Pip 子进程错误: 错误:无效要求:“pip '-U'”

I am trying to create an environment using environment.yaml, and for some reason the default pip installed in my environment by conda takes a long time to process the dependencies.

For this reason, I am trying to somehow upgrade the pip version in the conda envrionment file.

name: temp_env
channels:
  - pytorch
  - defaults
dependencies:
  - python=3.7
  - pytorch::pytorch=1.11.0
  - pytorch::torchvision=0.12.0
  - pytorch::cpuonly
  - pip
  - pip: 
      - -e '.[dev]'

The pip version that comes with this installation is pip 21.2.2 . I am trying to upgrade pip to latest version which as of now is 22.0.4. I can write a bash script to install the conda environment without the pip parts first and then install the package in it, but this is less than ideal. I'm trying to come up with a solution only using the YAML file.

I tried this:

  - pip>=22.0.4
  - pip: 
      - -e '.[dev]'

But apparently this version does not exist yet on conda's main channels. I also tried:

  - pip
  - pip:
    - -U pip
    - -e '.[dev]'

But this also does not work and throws an error.

['/path/to/miniconda3/envs/temp_env/bin/python', '-m', 'pip', 'install', '-U', '-r', '/path/to/folder/condaenv.0kdmzdvh.requirements.txt']

Pip subprocess error:
ERROR: Invalid requirement: "pip '-U'"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

贪恋 2025-01-25 11:13:16

conda-forge 渠道具有它。因此,

name: temp_env
channels:
  - pytorch
  - conda-forge
dependencies:
  - python=3.7
  - pytorch::pytorch=1.11.0
  - pytorch::torchvision=0.12.0
  - pytorch::cpuonly
  - pip>=22.0.4
  - pip: 
      - -e '.[dev]'

正如在错误中可以看出的那样,当Conda运行pip install命令时,它已经添加了-U。但是,主要问题是,要升级pip,然后使用升级pip将意味着运行两个顺序pip install命令,哪个不能独自一人做。 pip中的所有内容:列表已复制到sumplliant.txt,并有效地传递给pip install -u作为一个指令。

The conda-forge channel has it. So,

name: temp_env
channels:
  - pytorch
  - conda-forge
dependencies:
  - python=3.7
  - pytorch::pytorch=1.11.0
  - pytorch::torchvision=0.12.0
  - pytorch::cpuonly
  - pip>=22.0.4
  - pip: 
      - -e '.[dev]'

Also, as can be seen in the error, when Conda runs the pip install command, it already adds a -U. However, the main issue is that for one to upgrade pip and then use that upgraded pip would mean running two sequential pip install commands, which one cannot do from the YAML alone. Everything in the pip: list is copied to a requirements.txt and effectively passed to pip install -U as one directive.

硪扪都還晓 2025-01-25 11:13:16

我相信您需要进行pip install -U而不是pip -u

I believe you need to do pip install -U not pip -U.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文