Home > Blockchain >  Pip: How to override version of sub-dependency in requirements.txt?
Pip: How to override version of sub-dependency in requirements.txt?

Time:12-23

I recently switched to Apple Silicon and am trying to now install all packages in a Python project in the requirements.txt. However, since the architecture is different, I have trouble satisfying all requirements, specifically sub-dependencies.

requirements.txt

ethnicolr==0.8.1
# and many more, but this one is causing issues

Installing it with pip install -r requirements.txt yields

ERROR: Could not find a version that satisfies the requirement tensorflow==2.5.2 (from ethnicolr) (from versions: none)

TensorFlow 2.4.0 is available for this setup, and it should work with ethnicolr. So how do I override the version of the sub-dependency in requirements.txt?

I am using Mambaforge for virtual environments btw. because it is recommended to run a PyData Stack on Apple M1

CodePudding user response:

A way to workaround that is to explicitly set your dependencies and run pip install with a --no-deps parameter.

After setting my requirements.txt as:

ethnicolr==0.8.1
# and many more, but this one is causing issues
tensorflow==2.5.0 # You set this to whatever version you want to

I ran:

> pip install --no-deps -r requirements.txt                                                                                      
Collecting ethnicolr==0.8.1
  Using cached ethnicolr-0.8.1-py2.py3-none-any.whl (36.1 MB)
Collecting tensorflow==2.5.0
  Using cached tensorflow-2.5.0-cp39-cp39-manylinux2010_x86_64.whl (454.4 MB)
Installing collected packages: tensorflow, ethnicolr
Successfully installed ethnicolr-0.8.1 tensorflow-2.5.0

This implies a clear issue: You'll have to know beforehand which deps your packages use. To easily find out those, you can use pip-tools

CodePudding user response:

You should install a version of ethnicolr that doesn't have that specific requirement for the tensorflow version. pip install ethnicolr==0.2.0could work.

  • Related