我正在尝试修复我的一个virtualenv -我想将所有已安装的库重置为与生产相匹配的库。

有没有一种快速简单的方法来处理皮普?


当前回答

在Windows的命令Shell中,pip freeze | xargs pip uninstall -y命令不起作用。所以对于那些使用Windows的人,我想出了另一种方法。

将pip freeze命令中所有已安装的pip包的名称复制到一个.txt文件中。 然后,找到。txt文件所在的位置,运行pip uninstall -r *textfile.txt*命令

其他回答

从虚拟环境中删除所有包的最佳方法。

Windows PowerShell:

pip freeze > unins ; pip uninstall -y -r unins ; del unins

Windows命令提示符:

pip freeze > unins && pip uninstall -y -r unins && del unins

Linux:

pip3 freeze > unins ; pip3 uninstall -y -r unins ; rm unins

这是对我有用的命令:

pip list | awk '{print $1}' | xargs pip uninstall -y

如果你正在使用pew,你可以使用wipeenv命令:

皮尤wipeenv[环境]

我使用——user选项卸载安装在用户站点上的所有包。

pip3 freeze --user | xargs pip3 uninstall -y

最快的方法是完全重做virtualenv。我假设你有一个符合生产的requirements.txt文件,如果没有的话:

# On production:
pip freeze > reqs.txt

# On your machine:
rm $VIRTUALENV_DIRECTORY
mkdir $VIRTUALENV_DIRECTORY
pip install -r reqs.txt