Trying to Install Pip using python-pip
Your apt-cache policy python
output told me that you could not install the correct python
version (2.7.x) from the repositories. As Python is located in the main
repository, we should first try to activate that repository (again) and update the package lists:
sudo add-apt-repository main
sudo apt-get update
As you got an invalid signature (BADSIG) error, we completely remove all package lists and re-download them. Also in case the error prevented it from working, we try to enable the main
repository again.
sudo rm -rf /var/lib/apt/lists/*
sudo add-apt-repository main
sudo apt-get update
Now the new apt-cache policy python
output shows the correct version available from the server, so we can now force the downgrade of our package python
to the required version:
sudo apt-get install python=2.7.5-5ubuntu3
We then need to clean the locally cached wrong 3.5 version and just empty the entire package cache therefore:
sudo apt-get clean
Then we let it try to upgrade all remaining packages and hope for the best:
sudo apt-get upgrade
Related videos on Youtube
![Ritesh Shakya](https://lh6.googleusercontent.com/-EW4h7yJIQLM/AAAAAAAAAAI/AAAAAAAAGbg/S2ekaHlYMvU/photo.jpg?sz=256)
Ritesh Shakya
Profession Wise:- Work at Deerwalk Inc as a Java Developer working with hadoop and Cascading Currently Learning: Python and Mobile Game Development. Interested In: Deep Learning, Cyber Securty For Fun : Play a lot of MOBA games :D
Updated on September 18, 2022Comments
-
Ritesh Shakya almost 2 years
Was trying to install Pip through the command
I was getting the following error message.
You might want to run 'apt-get -f install' to correct these: The following packages have unmet dependencies: ..... E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
Also as stated in the terminal tried using the command
sudo apt-get -f install
Which gave this in return
Correcting dependencies... failed. The following packages have unmet dependencies: ..... E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages. E: Unable to correct dependencies
As Suggested in some threads I tried using
sudo apt-get install --fix-broken && sudo apt-get autoremove && sudo apt-get update && sudo apt-get install samba
but didnt work. I also tried removing the individual package but this failed as well. I have both python 2.7 as well 3.5.1 installed.My
python -V
returnsPython 2.7.6
.My
python3 -V
returnsPython 3.5.1
.My
apt-cache policy python python3
returnspython: Installed: 3.5.1-1 Candidate: 3.5.1-1 Version table: *** 3.5.1-1 0 100 /var/lib/dpkg/status python3: Installed: 3.4.0-0ubuntu2 Candidate: 3.4.0-0ubuntu2 Version table: *** 3.4.0-0ubuntu2 0 100 /var/lib/dpkg/status
After using
sudo rm -rf /var/lib/apt/lists/* ; sudo apt-get update ; sudo add-apt-repository main; apt-cache policy python
python: Installed: 3.5.1-1 Candidate: 3.5.1-1 Version table: *** 3.5.1-1 0 100 /var/lib/dpkg/status 2.7.5-5ubuntu3 0 500 http://archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages
Thanks in advance
-
Byte Commander over 8 yearsPlease show me the output of
python -V ; python3 -V ; apt-cache policy python python3
. Make sure you edit your question to provide it, because comments don't preserve formatting. Thanks! -
Byte Commander over 8 yearsThis is strange, did you modify the output of
apt-cache policy python
and remove some lines? Please runsudo add-apt-repository main && sudo apt-get update && apt-cache policy python
and add the output to your question again. The packagepython
must provide a Python version 2.7, not 3.5. I wonder why you don't see any installation candidates except the cached one. -
Ritesh Shakya over 8 yearsI didnt do anything to modify the code. The command you mentioned returned
hive.ubuntu.com trusty Release: The following signatures were invalid: BADSIG 16126D3A3E5C1192 Ubuntu Extras Archive Automatic Signing Key <[email protected]> W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/trusty/Release W: Some index files failed to download. They have been ignored, or old ones used instead. python: Installed: 3.5.1-1 Candidate: 3.5.1-1 Version table: *** 3.5.1-1 0 100 /var/lib/dpkg/status
-
Byte Commander over 8 yearsPlease run
sudo rm -rf /var/lib/apt/lists/* ; sudo apt-get update ; sudo add-apt-repository main
. Any errors? What output doesapt-cache policy python
give you now? (And still: edit your question. Comments have ugly formatting) -
Byte Commander over 8 yearsOkay, that looks good. Now you can downgrade the
python
package to the required 2.7.5-5 usingsudo apt-get install python=2.7.5-5ubuntu3
. Please run that andsudo apt-get clean
andsudo apt-get upgrade
and finally try your original commands again afterwards. Tell me if it worked and I'll convert these comments into an answer. -
Ritesh Shakya over 8 yearsSorry I ended up crashing the office machine. Couldn't reply from there. apt-get -f install removed all dependent packages and computer refused to start.
-
Byte Commander over 8 yearsCan you upload the content of you file
/var/log/apt/history.log
to e.g. pastebin.com and give me the link? That way we can find out which packages exactly got removed and reinstall them manually in the correct version. -
Ritesh Shakya over 8 yearsCurrently I'm at home will do so as soon as I reach office tomorrow.. Thanks a million
-
Byte Commander over 8 yearsWhat might also help to recover your packages is this question: askubuntu.com/q/249367/367990
-
Ritesh Shakya over 8 yearsHello here is the pastebin link you requested [pastebin.com/kWaZkUGN]
-
Ritesh Shakya over 8 yearsKinda got back the important packages using
apt-get install --reinstall gdm; dpkg-reconfigure gdm; apt-get install --reinstall gnome;
now tring to reinstall additional packages. Also the pip issue has been solved thanks a ton. how do i flag as resolved -
Byte Commander over 8 yearsAs you managed to resolve the uninstalled packages yourself, I don't really need the pastebin any more. But to mark a question as solved, you accept an answer by clicking the grey tick symbol on the left of it. I've converted my comments into an answer for you. Oh, and make sure you have read our little tour page to learn the most important things about how this site works. Thanks!
-