ChatGPT解决这个技术问题 Extra ChatGPT

anaconda/conda - install a specific package version

I want to install the 'rope' package in my current active environment using conda. Currently, the following 'rope' versions are available:

(data_downloader)user@user-ThinkPad ~/code/data_downloader $ conda search rope
Using Anaconda Cloud api site https://api.anaconda.org
Fetching package metadata: ....
cached-property              1.2.0                    py27_0  defaults        
                             1.2.0                    py34_0  defaults        
                             1.2.0                    py35_0  defaults        
                             1.3.0                    py27_0  defaults        
                             1.3.0                    py34_0  defaults        
                             1.3.0                    py35_0  defaults        
rope                         0.9.4                    py26_0  defaults        
                             0.9.4                    py27_0  defaults        
                             0.9.4                    py33_0  defaults        
                             0.9.4                    py34_0  defaults        
                             0.9.4                    py26_1  defaults        
                             0.9.4                    py27_1  defaults        
                             0.9.4                    py33_1  defaults        
                             0.9.4                    py34_1  defaults        
                          .  0.9.4                    py35_1  defaults        

I would like to install the following one:

                         1.3.0                    py35_0  defaults        

I've tried all sorts of permutations of 'conda install' which I'm not going to list here because none of them are correct.

I am also not sure what the py35_0 is (I'm assuming this is the version of the python against which the package was built?) and I also don't know what 'defaults' means?

did you try conda install package=version? e.g. conda install matplotlib=1.4.3
@CharlieParker -- Thanks that worked. I wasn't able to gather that using equals in that fashion would work from reading the help text. -- The help text really made it seem like I would have to somehow correlate the revision number to a version number and specify it that way (with --revision). Thanks again!
if you want at least a specific version don't forget the quotes conda install -y networkx">=2.5"

C
Chris

To install a specific package:

conda install <pkg>=<version>

eg:

conda install matplotlib=1.4.3

For more complex expressions, the relation can be quoted:

conda install 'matplotlib>=1.4.3'

# or

conda install "matplotlib>=1.4.3"

is there a way to say "at least version 2.5"? e.g. conda install -y networkx=>2.5?
this worked for me: conda install -y networkx">=2.5"
this didn't work for me: conda install samtools>=1.14
@ÖmerAn one must prevent shell from evaluating the > symbol: conda install 'samtools>=1.14'
W
Wombatz

There is no version 1.3.0 for rope. 1.3.0 refers to the package cached-property. The highest available version of rope is 0.9.4.

You can install different versions with conda install package=version. But in this case there is only one version of rope so you don't need that.

The reason you see the cached-property in this listing is because it contains the string "rope": "cached-p rope erty"

py35_0 means that you need python version 3.5 for this specific version. If you only have python3.4 and the package is only for version 3.5 you cannot install it with conda.

I am not quite sure on the defaults either. It should be an indication that this package is inside the default conda channel.


Thanks - yes, I'm starting with conda and totally missed that 'cached-property' is just another package.
@s5s The defaults does indicate that the package will be installed from the default package repository. The pyXY indicates that that particular package is available for Python X.Y, while the _Z indicates the "build number" which is incremented when the way that the package is created is changed, but the actual code in the package is unchanged.
Command to install specific package conda install rope=0.9.4 This is a link to Conda Documentation
How can I choose python version? If I want to install with 1.3.0 version of package for python 3.5?
for people looking for an actual answer with executable code: conda install <pkg>=<version> e.g. conda install matplotlib=1.4.3
J
Jonathan L

If any of these characters, '>', '<', '|' or '*', are used, a single or double quotes must be used

conda install [-y] package">=version"
conda install [-y] package'>=low_version, <=high_version'
conda install [-y] "package>=low_version, <high_version"

conda install -y torchvision">=0.3.0"
conda install  openpyxl'>=2.4.10,<=2.6.0'
conda install "openpyxl>=2.4.10,<3.0.0"

where option -y, --yes Do not ask for confirmation.

Here is a summary:

Format         Sample Specification     Results
Exact          qtconsole==4.5.1         4.5.1
Fuzzy          qtconsole=4.5            4.5.0, 4.5.1, ..., etc.
>=, >, <, <=  "qtconsole>=4.5"          4.5.0 or higher
               qtconsole"<4.6"          less than 4.6.0

OR            "qtconsole=4.5.1|4.5.2"   4.5.1, 4.5.2
AND           "qtconsole>=4.3.1,<4.6"   4.3.1 or higher but less than 4.6.0

Potion of the above information credit to Conda Cheat Sheet

Tested on conda 4.7.12


The quotes don’t seem mandatory for anaconda-project.yml.
Now that makes perfect sense in a console (and the same goes for pip) : without quotes the smaller/larger-than characters will be interpreted as redirections.
This is the best answer, in terms of being most complete and providing a direct answer to the question. This gets my up-vote !!
why are the quotes needed?
@CharlieParker, the quotes make characters like '>', '<', '|' or '*' get properly interpreted