使用环境中的conda中的PIP升级到最新版本。
我正在尝试使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
conda-forge 渠道具有它。因此,
正如在错误中可以看出的那样,当Conda运行
pip install
命令时,它已经添加了-U
。但是,主要问题是,要升级pip
,然后使用升级pip
将意味着运行两个顺序pip install
命令,哪个不能独自一人做。pip中的所有内容:
列表已复制到sumplliant.txt
,并有效地传递给pip install -u
作为一个指令。The conda-forge channel has it. So,
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 upgradepip
and then use that upgradedpip
would mean running two sequentialpip install
commands, which one cannot do from the YAML alone. Everything in thepip:
list is copied to arequirements.txt
and effectively passed topip install -U
as one directive.我相信您需要进行
pip install -U
而不是pip -u
。I believe you need to do
pip install -U
notpip -U
.