224

Is there any way to force install a pip python package ignoring all it's dependencies that cannot be satisfied?

(I don't care how "wrong" it is to do so, I just need to do it, any logic and reasoning aside...)

petezurich
  • 7,683
  • 8
  • 34
  • 51
NeuronQ
  • 6,637
  • 9
  • 39
  • 57

3 Answers3

343

pip has a --no-dependencies switch. You should use that.

For more information, run pip install -h, where you'll see this line:

--no-deps, --no-dependencies
                        Ignore package dependencies
Jeff Tratner
  • 15,152
  • 4
  • 45
  • 65
  • 35
    how to pass this within a requirements.txt file? – Austin Aug 03 '15 at 23:27
  • 10
    To run with a requirements.txt, it would be: `pip install --no-deps -r requirements.txt` – Graham Place May 16 '18 at 06:51
  • Anything like this to prevent installing recommended packages like with `apt-get install --no-install-recommends`? – Connor Jul 12 '18 at 21:23
  • 1
    @Connor there is no equivalent to "recommended packages" in any of the standard Python packaging tools: distutils, setuptools, pip. Setuptools (and pip) has "extras", but they must be explicitly selected and installed by the user. – shadowtalker Oct 18 '18 at 19:51
  • 2
    This doesn't seem to work for a local package. `pip install --no-deps /path/to/package` gives the message "Installing build dependencies" and attempts to install build dependencies. – Ben Caine May 06 '21 at 15:38
11

When I were trying install librosa package with pip (pip install librosa), this error were appeared:

ERROR: Cannot uninstall 'llvmlite'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.

I tried to remove llvmlite, but pip uninstall could not remove it. So, I used capability of ignore of pip by this code:

pip install librosa --ignore-installed llvmlite

Indeed, you can use this rule for ignoring a package you don't want to consider:

pip install {package you want to install} --ignore-installed {installed package you don't want to consider}
Hamed Baziyad
  • 1,786
  • 5
  • 23
  • 35
  • 11
    this is not exactly what the op asked for. according to the man page -I, --ignore-installed Ignore the installed packages (reinstalling instead). this flag will explicilty reinstall the specified packages, even if they are installed already – madmuffin Apr 17 '20 at 13:12
  • Is there a way to see which packages will be effected before installing? How about telling `pip` to ignore many packages? – Royi Sep 11 '21 at 12:30
7

Try the following:

pip install --no-deps <LIB_NAME>

or

pip install --no-dependencies <LIB_NAME>

or

pip install --no-deps -r requirements.txt

or

pip install --no-dependencies -r requirements.txt
Charlie Parker
  • 13,538
  • 41
  • 149
  • 255