How to reinstall a pip package even if it exists

后端 未结 2 1703
Happy的楠姐
Happy的楠姐 2020-12-31 16:09

I want to run a pip install -r requirements.txt command;

I want to run the same command over and over again;

The issue is that requirement

2条回答
  •  -上瘾入骨i
    2020-12-31 16:49

    With --force-reinstall, existing packages (and dependencies) are uninstalled first, while with --ignore-installed, they are not.

    So --force-reinstall is the preferred choice and --ignore-installed is more of an emergency option.

    Here's a sample output:

    > pip install --force-reinstall ipdb
    Collecting ipdb
    Collecting ipython<6.0.0,>=5.0.0; python_version == "2.7" (from ipdb)
      Using cached https://<...>/ipython-5.8.0-py2-none-any.whl
    Collecting setuptools (from ipdb)
    <...>
    Installing collected packages: six, wcwidth, prompt-toolkit, decorator, setuptools, <...>
      Found existing installation: six 1.11.0
        Uninstalling six-1.11.0:
          Successfully uninstalled six-1.11.0
      Found existing installation: wcwidth 0.1.7
        Uninstalling wcwidth-0.1.7:
          Successfully uninstalled wcwidth-0.1.7
    <...>
    Successfully installed backports.shutil-get-terminal-size-1.0.0 colorama-0.4.0 <...>
    
    
    > pip install --ignore-installed ipdb
    Collecting ipdb
    Collecting ipython<6.0.0,>=5.0.0; python_version == "2.7" (from ipdb)
    <...>
    Collecting setuptools (from ipdb)
    <...>
    Installing collected packages: six, wcwidth, prompt-toolkit, decorator, setuptools, <...>
    Successfully installed <...>
    

提交回复
热议问题