一次对requirements环境的配置

事情是这样的,我需要跑通一个代码,因此要配置环境,但是并不能利用requirements中给的指令直接配置,于是开始找一些其他的解决方法。作为一名小白,总是绕很多弯路。

记下一些蜿蜒。

首先,摘录requirements中写的

This file may be used to create an environment using:

$ conda create --name <env> --file <this file>

platform: linux-64

_libgcc_mutex=0.1=conda_forge

cudatoolkit=10.2.89=h713d32c_10

cycler=0.11.0=pypi_0

ffmpeg=4.3=hf484d3e_0

..

于是非常自然的直接用给的命令,不行。

怎么办呢?

我的最终解决方法:

找到python版本,并按照这个版本先创建一个环境。

再进行 conda install --file requirements.txt

(为什么不是pip install -r requirements.txt? 那是因为pip要求里面的版本号都是==)

然后出现了 the following packages couldn't .... from current channels

此时博主的源已经是清华源和官方都有的了,因此不是channels的问题。

然后仔细查看了哪些包不能被下载,发现他们都有一个共同特点:

那就是 cycler=0.11.0=pypi_0

第二个版本号都是含pypi的暗示我们需要用pip下载,于是放到一个文件里,用pip批量下载这些。

下载的时候发现,怎么还有不能下载的?

我的pip没有添加国内源,于是用这个命令pip install torch==1.12.0 -i https://mirrors.aliyun.com/pypi/simple

一个一个再用pip下载试试,都成功了。

这会再 conda install --file requirements.txt(这里要把requirements中下载过的都删掉)

发现 ffmpeg=4.3=hf484d3e_0 下载不下来,因此添加源

复制代码
channels:
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/fastai/
  - http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
  - defaults
  - conda-forge
show_channel_urls: true

使用conda-forge就能下载下来啦。

菜菜的我,解决了菜菜的问题。

2024.3.13

conda install -c conda-forge ffmpeg==4.3=hf484d3e_0