是否可以在 Anaconda 中锁定包的版本?
Is it possible to lock versions of packages in Anaconda?
我在 Windows xp 上安装了 Anaconda 3 2.3.0。它应该是 last version of anaconda to support windows xp,因为它包含 python 3.4.3,而 python 3.4.x 是支持 python 的最后一个版本 windows xp.
使用
安装包时
conda install
,其依赖项之一是将 conda 更新为 conda 4.x。当 运行ning conda install 时,conda 4.x 在命令行中崩溃。这使 anaconda 无法使用,我卸载了 anaconda。
我的问题是,是否可以锁定包的版本?对于两个用例:
- 锁定并忘记:对于我不想让它们更新的包,我需要运行一个命令来锁定它们一次,这样它们就永远不会作为依赖项更新
- 忽略更新:安装一个包,同时忽略更新此更新中按名称传递的某些包。
如果 2 个用例中只有一个是可能的或已知的或更容易的,请将其写为答案。
这里有两位。首先,您可以通过更改配置选项 auto_update_conda
to False
:
来防止 conda 自动更新
conda config --set auto_update_conda False
另一位是将包固定到特定版本。对于那些您不想更新的包,您可以通过向环境的 conda-meta
目录中名为 pinned
的文件(您可能需要创建它)添加一行来固定版本。语法是
[The code] below [placed in conda-meta/pinned
] forces NumPy to stay on the 1.7 series, which is any version that starts with 1.7, and forces SciPy to stay at exactly version 0.14.2:
numpy 1.7.*
scipy ==0.14.2
有关详细信息,请参阅 the documentation。
尝试
pip install <package name==version no*>
例如
pip install musdb==0.2.*
那会固定你的包裹
conda install
的 Pin 图 (=):package=1.0
对比
pip install
的 Pin 图 (==):package==1.0
我在 Windows xp 上安装了 Anaconda 3 2.3.0。它应该是 last version of anaconda to support windows xp,因为它包含 python 3.4.3,而 python 3.4.x 是支持 python 的最后一个版本 windows xp.
使用
安装包时conda install
,其依赖项之一是将 conda 更新为 conda 4.x。当 运行ning conda install 时,conda 4.x 在命令行中崩溃。这使 anaconda 无法使用,我卸载了 anaconda。
我的问题是,是否可以锁定包的版本?对于两个用例:
- 锁定并忘记:对于我不想让它们更新的包,我需要运行一个命令来锁定它们一次,这样它们就永远不会作为依赖项更新
- 忽略更新:安装一个包,同时忽略更新此更新中按名称传递的某些包。
如果 2 个用例中只有一个是可能的或已知的或更容易的,请将其写为答案。
这里有两位。首先,您可以通过更改配置选项 auto_update_conda
to False
:
conda config --set auto_update_conda False
另一位是将包固定到特定版本。对于那些您不想更新的包,您可以通过向环境的 conda-meta
目录中名为 pinned
的文件(您可能需要创建它)添加一行来固定版本。语法是
[The code] below [placed in
conda-meta/pinned
] forces NumPy to stay on the 1.7 series, which is any version that starts with 1.7, and forces SciPy to stay at exactly version 0.14.2:numpy 1.7.* scipy ==0.14.2
有关详细信息,请参阅 the documentation。
尝试
pip install <package name==version no*>
例如
pip install musdb==0.2.*
那会固定你的包裹
conda install
的 Pin 图 (=):package=1.0
对比
pip install
的 Pin 图 (==):package==1.0