What is the easiest way to remove all packages ins

2019-01-05 06:46发布

I'm trying to fix up one of my virtualenvs - I'd like to reset all of the installed libraries back to the ones that match production.

Is there a quick and easy way to do this with pip?

18条回答
The star\"
2楼-- · 2019-01-05 07:24

The quickest way is to remake the virtualenv completely. I'm assuming you have a requirements.txt file that matches production, if not:

# On production:
pip freeze > reqs.txt

# On your machine:
rmvirtualenv MYENV
mkvirtualenv MYENV
pip install -r reqs.txt
查看更多
仙女界的扛把子
3楼-- · 2019-01-05 07:26

For Windows users, this is what I use on Windows PowerShell

 pip uninstall -y (pip freeze)
查看更多
孤傲高冷的网名
4楼-- · 2019-01-05 07:26

In Command Shell of Windows, the command pip freeze | xargs pip uninstall -y won't work. So for those of you using Windows, I've figured out an alternative way to do so.

  1. Copy all the names of the installed packages of pip from the pip freeze command to a .txt file.
  2. Then, go the location of your .txt file and run the command pip uninstall -r *textfile.txt*
查看更多
叼着烟拽天下
5楼-- · 2019-01-05 07:28
家丑人穷心不美
6楼-- · 2019-01-05 07:29

I think this works with the latest

virtualenv --clear MYENV
查看更多
我只想做你的唯一
7楼-- · 2019-01-05 07:29

In my case, I had accidentally installed a number of packages globally using a Homebrew-installed pip on macOS. The easiest way to revert to the default packages was a simple:

$ brew reinstall python

Or, if you were using pip3:

$ brew reinstall python3
查看更多
登录 后发表回答