What is the easiest way to remove all packages installed by pip

0 votes
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?
Dec 4, 2020 in Python by anonymous
• 10,520 points
634 views

1 answer to this question.

0 votes

I've found this snippet as an alternative solution. It's a more graceful removal of libraries than remaking the virtualenv:

pip freeze | xargs pip uninstall -y

In case you have packages installed via VCS, you need to exclude those lines and remove the packages manually (elevated from the comments below):

pip freeze | grep -v "^-e" | xargs pip uninstall -y
answered Dec 4, 2020 by Gitika
• 65,890 points

Related Questions In Python

0 votes
1 answer

What is the easiest way to implement 'IN' and 'NOT IN' in Pandas dataframe?

You can use pd.Series.isin. For "IN" use: something.isin(somewhere) Or for "NOT ...READ MORE

answered Aug 23, 2019 in Python by Arvind
• 3,050 points
12,736 views
0 votes
1 answer
0 votes
1 answer

What is the best way to remove accents in a Python unicode string?

Hello @kartik, Some languages have combining diacritics as ...READ MORE

answered May 11, 2020 in Python by Niroj
• 82,880 points
7,190 views
0 votes
1 answer

What is the preferred way to concatenate strings in python??

If the strings you are concatenating are ...READ MORE

answered Dec 21, 2018 in Python by charlie_brown
• 7,720 points
778 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,358 views
0 votes
1 answer
0 votes
1 answer

What is the function to randomize the items of a list in-place?

Hello @Roshni, Python has a built-in module called ...READ MORE

answered Jun 26, 2020 in Python by Gitika
• 65,890 points
1,338 views
0 votes
1 answer

what is vm options ? I installed Pycharm on my pc but it shows no vm options file found . What should i do please help me to fix it

Hi, @Mushfiqkhantrial, It is important to run pycharm.sh from the bin folder. The VM ...READ MORE

answered Oct 4, 2020 in Python by Gitika
• 65,890 points
1,783 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP