Skip to content

Instantly share code, notes, and snippets.

@stucka
Last active November 23, 2022 02:50
Show Gist options
  • Star 21 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save stucka/09cbd34c8bfec0c37dd8a122362ef9c1 to your computer and use it in GitHub Desktop.
Save stucka/09cbd34c8bfec0c37dd8a122362ef9c1 to your computer and use it in GitHub Desktop.
Force pip to reinstall all Python packages (works great with https://gist.github.com/stucka/0ced1cc71e1a5c374a18874471636d69)
#!/bin/bash
apt-get install libxml2-dev libssl-dev libffi-dev libxslt1-dev python-dev libjpeg-dev
pip freeze --local >pipfreeze.txt
tr '\n' ' ' < pipfreeze.txt >pipfreeze2.txt
pip install --upgrade --force-reinstall `cat pipfreeze2.txt`
@Michael-Cook-Bose
Copy link

FYI, the tr step isn't necessary.

@landonepps
Copy link

I think you can just do this:

pip freeze --local >pipfreeze.txt
pip install --upgrade --force-reinstall -r pipfreeze.txt

@mikbuch
Copy link

mikbuch commented Aug 3, 2018

Thank you, @landonepps's two-liner did the job when I was fighting ipython not launching on OSX High Sierra. There supposedly were dependency problems (despite module being installed) but I noticed that reinstalling troublesome module with pip was fixing the issue. As I had 108 python modules installed in total, these two lines spared me a lot of time. 👍

@EliasHasle
Copy link

To avoid reinstalling from corrupted files, one may add the --no-cache-dir option. (Will download all packages again.)

@audricchabert
Copy link

Thank you, @landonepps's two-liner did the job for the error : from robotide import main importerror cannot import name 'main'

@subimage
Copy link

Helped me fix a python dependency problem on Mac OS Big Sur after moving from brew's version to pyenv. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment