Search code examples
pythonanaconda

How to install packages from Requirement.txt in python using anaconda?


I am confused on how to install all the packages from requirements.txt shared by another person for a python project strictly using Anaconda only in Windows os.

  1. I have installed Anaconda navigator. Should I do it in navigator or in conda prompt ?
  2. Do I need to create an environment first and then activate it and then run command pip install requirements.txt in that environment ?

Please, could you suggest a better way to install the packages from anaconda using requirements.txt and run the python project?


Solution

  • conda uses an environment.yaml file instead of requirements.txt, but you can include one in the other:

    # environment.yaml
    
    name: test-env
    channels:
      - conda-forge
    dependencies:
      - python>=3.5
      - anaconda
      - pip
      - pip:
        - -r file:requirements.txt
    

    Then use conda to create the environment via

    conda env create -f environment.yaml