Rishabh Samra
Rishabh Samra

Reputation: 11

Not able to install dependencies mentioned in requirements.txt in my conda environment

I am not able to install dependencies mentioned in requirements.txt (https://github.com/liuzhen03/ADNet) via pip install. It is being installed in some different path where a memory error is raised:

ERROR: Could not install packages due to an OSError:
[Errno 28] No space left on device

I want to install it only in my Conda environment. I tried

conda install --file requirement.txt

but still getting the same error as attached in the screenshot below.

Can someone help me sort this out?

enter image description here

Upvotes: 0

Views: 817

Answers (1)

merv
merv

Reputation: 76700

Conda and PyPI packages don't necessarily use the same package names, so one can't simply feed Conda a pip freeze file and treat it like it came from conda list --export. However, Conda environments fully support Pip, so one can take two approaches.

Option 1: PyPI-only packages

One can use Conda's YAML environment specification to define the environment and Python version, and let Pip install the rest.

adnet.yaml

name: adnet
channels:
  - conda-forge
dependencies:
  # core 
  - python=3.7
  - pip
  
  # PyPI packages
  - pip:
    - -r https://github.com/liuzhen03/ADNet/raw/main/requirement.txt

The specification of Python 3.7 is because the scikit-image==0.16.2 specified in the requirements file is from 2019, so that seems like the appropriate Python to be using.

Option 2: Prefer Conda packages

The other option is to do a little work and see what packages are available through Conda, and source from there first. This has the advantage that all Conda packages are precompiled and you can add in stuff like specifying a BLAS implementation or CUDA version.

Basically, the only thing not on Conda is thop, and the two other packages Conda complained about, torch and opencv-python, go by the names pytorch and py-opencv in the Conda repository, respectively. So, a basic YAML translation would look like:

adnet.yaml

name: so-adnet-conda
channels:
  - pytorch
  - conda-forge
dependencies:
  # core
  - python=3.7
  - pip
  # specify blas or cuda versions here

  # Conda packages
  - imageio=2.9.0
  - matplotlib=3.3.3
  - scikit-image=0.16.2
  - easydict=1.9
  - pytorch=1.2.0
  - torchvision=0.4.0
  - pillow
  - py-opencv >=4.0,<5.0
  - tensorboardX=2.1
  - tensorboard
  - future
  - lmdb
  - pyarrow

  # PyPI packages
  - pip:
    - thop

Upvotes: 1

Related Questions