Sparsh Kedia
Sparsh Kedia

Reputation: 81

Checking package versions in a miniconda environment

I hava a conda environment called test and a requirements file-requirements.txt.

What i need to achieve is that i need to check the versions of different packages against those in requirements.txt and display which are upto date and which are not.

I need to write a python script for the task. For eg: if requirements.txt has django==2.0.6, i have to check against the installed version of django in the test environment and display accordingly.

The steps that i thought are :

  1. Activating the environment inside script
  2. running "conda list" command and saving all the packages along with their versions in a map as key-value pairs
  3. matching against the requirements.txt

How to activate the environment inside a python script using "conda activate test" and run the command "conda list"?

Upvotes: 1

Views: 4067

Answers (1)

FlyingTeller
FlyingTeller

Reputation: 20599

conda list accepts the argument -n to specify an environment like this:

conda list -n test

so no need to activate the conda env

Upvotes: 2

Related Questions