使用conda --file参数安装cudnn=6.0.0遇PackageNotFoundError求助
conda install --file fail to find cudnn=6.0.0 but the direct command works? Let's break down why you're seeing this discrepancy and how to fix it:
The Root Cause
When you use conda install --file, Conda parses the package list in a stricter, more literal way compared to specifying packages directly on the command line.
In your case, cudnn=6.0.0 is only hosted in the anaconda channel. When you run the direct command:
conda install -y cudnn=6.0.0 -p <env_path>
Conda automatically searches through all configured channels (including the anaconda channel) to locate the matching package version.
However, when using --file b.txt, Conda doesn't automatically associate the package with its required channel unless explicitly told to do so. Your b.txt only lists cudnn=6.0.0, so Conda only checks the channels shown in your error message (defaults + conda-forge) where this specific version isn't available.
Fixes to Try
1. Add the channel prefix to your package file
Modify b.txt to explicitly tie the package to the anaconda channel:
anaconda::cudnn=6.0.0
Then re-run your original command:
conda install -y --file b.txt -p <env_path>
2. Explicitly include the channel in the install command
If you don't want to edit the package file, add the -c anaconda flag to force Conda to search that channel when processing the file:
conda install -y --file b.txt -c anaconda -p <env_path>
Either approach should let Conda locate and install cudnn=6.0.0 successfully via the package file.
内容的提问来源于stack exchange,提问作者user2851669

