The Pbms answer here is the right way to do this, assuming you have an existing copy environment. Conda is fully capable of installing both Conda and pip packages as specified in environment.yml . I wanted to document the whole process in more detail. Note that I use folder-based environments, so I added --prefix [path to environment folder] to most commands.
Suppose you installed the environment for an existing project in a folder named env in the current folder, for example:
conda create
You must generate environment.yml for this project environment, for example:
conda env export --prefix ./env > environment.yml
You would create a new environment in some other folder by copying environment.yml there and then running it from there:
conda env create
You will get an already existing environment corresponding to environment.yml , once again copying environment.yml there and then running it from there:
conda env update
If the environment in question is active, you can check the status of its packages as follows:
conda list
This is a shortened version of what this command can print (note that pip packages are marked with pypi ):
# Name Version Build Channel pip 19.2.2 py37_0 python 3.7.4 h5263a28_0 numpy 1.16.4 py37h19fb1c0_0 pandas 0.25.1 py37ha925a31_0 pyodbc 4.0.27 py37ha925a31_0 ibm-db 3.0.1 pypi_0 pypi ibm-db-sa 0.3.5 pypi_0 pypi
Finally, this is a shortened version of what environment.yml might look like (note that pip packages are listed in their own category):
dependencies: - pip=19.2.2=py37_0 - python=3.7.4=h5263a28_0 - numpy=1.16.4=py37h19fb1c0_0 - pandas=0.25.1=py37ha925a31_0 - pyodbc=4.0.27=py37ha925a31_0 - pip: - ibm-db==3.0.1 - ibm-db-sa==0.3.5
Keep in mind that sharing Conda and pip can cause some heartburn, as they can unknowingly destroy dependencies on each other. You must first install all your Conda packages, and then all your pip packages, and not interleave them. If your environment is broken, the official recommendation is to delete and recreate it (from your environment.yml file). See this guide for more information:
https://www.anaconda.com/using-pip-in-a-conda-environment/