Remove mercurial-common from Ubuntu 15.04 - python

I'm having Python 2.x problems on Ubuntu 15.04. I wanted to completely uninstall and reinstall Python. I can't uninstall Python because mercurial-common depends on it. I try to remove that and I get an error:
➜ ~ sudo apt-get remove --purge mercurial-common
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
gnome-control-center-data gnome-icon-theme gnome-icon-theme-symbolic gnome-settings-daemon libcolord-gtk1 libexpat1-dev libgoa-backend-1.0-1 libjs-excanvas libpython3-dev
libpython3.4-dev python3-colorama python3-dev python3-distlib python3-wheel python3.4-dev
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
mercurial-common*
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 8,610 kB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 206144 files and directories currently installed.)
Removing mercurial-common (3.1.2-2+deb8u1build0.15.04.2) ...
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
ImportError: No module named site
dpkg: error processing package mercurial-common (--purge):
subprocess installed pre-removal script returned error exit status 1
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
ImportError: No module named site
dpkg: error while cleaning up:
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
mercurial-common
E: Sub-process /usr/bin/dpkg returned an error code (1)

The mercurial-common removal scripts use python
/var/lib/dpkg/info/mercurial-common.prerm
If you type which pyclean I assume it exists.
However I suspect you python problems prevent it working. (you could try running it manually to verify this)
Unfortunately pyclean is in package python-minimal so you prolly can't uninstall this before mercurial-common.
you could try just removing it manually by:
sudo mv /usr/bin/pyclean /usr/bin/pyclean.backup
(Just remember to put it back).
Alternatively rather than completely removing python you could try just reinstalling python package .deb over the top of the existing install using dpkg --install

Related

apt - dpkg python-rpi.gpio dependency problems

Every time i try to install something, upgrade or autoremove this error happens!
I've searched the web and tried some fixes but they don't seem to work, I don't have python2.7 installed only 3 and can't install python2 or anything because of this. I've tryed to sudo rm python-rpi.gpio_0.7.0-0.1~bpo10+4_armhf.deb but the file will keep comming. Pls I really need some help since I've got some work on my pi and don't want to get a new image
sudo apt autoremove
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
python-rpi.gpio
The following packages will be upgraded:
python-rpi.gpio
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
18 not fully installed or removed.
Need to get 0 B/20.7 kB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Reading changelogs... Done
(Reading database ... 152893 files and directories currently installed.)
Preparing to unpack .../python-rpi.gpio_0.7.0-0.1~bpo10+4_armhf.deb ...
/var/lib/dpkg/info/python-rpi.gpio.prerm: 6: /var/lib/dpkg/info/python-rpi.gpio.prerm: pyclean: Too many levels of symbolic links
dpkg: warning: old python-rpi.gpio package pre-removal script subprocess returned error exit status 2
dpkg: trying script from the new package instead ...
/var/lib/dpkg/tmp.ci/prerm: 6: /var/lib/dpkg/tmp.ci/prerm: pyclean: Too many levels of symbolic links
dpkg: error processing archive /var/cache/apt/archives/python-rpi.gpio_0.7.0-0.1~bpo10+4_armhf.deb (--unpack):
new python-rpi.gpio package pre-removal script subprocess returned error exit status 2
/var/lib/dpkg/info/python-rpi.gpio.postinst: 6: /var/lib/dpkg/info/python-rpi.gpio.postinst: pycompile: Too many levels of symbolic links
dpkg: error while cleaning up:
installed python-rpi.gpio package post-installation script subprocess returned error exit status 2
Errors were encountered while processing:
/var/cache/apt/archives/python-rpi.gpio_0.7.0-0.1~bpo10+4_armhf.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
Some notes: I really really don't want to change the SD Card and parcially lose what I have, second I've tried sudo apt-get install -f and sudo apt update --fix-missing when i followed this guide the sudo dpkg --remove --force-remove --reinstreq command was showing this error dpkg: error: unknown force/refuse option 'remove'
As it turns out I still had remainnings of Python2 and Python3 binaries and those were not linked properly by the OS, this means that Python3 was linked to Python2 and vice-versa.
To get it working I had to:
Uninstall the Python2 dependencies
Get the link working correctly
Reinstall Python2 with wget
Verify if all links are working correctly (for Raspbian this means):
python --version links to Python2
python2 --version links to Python2
python3 --version links to Python3
Use the following commands:
sudo dpkg -i --force-overwrite /var/cache/apt/archives//python-rpi.gpio_0.7.0-0.1~bpo10+4_armhf.deb
Still have the same problem, use:
sudo mv /var/lib/dpkg/info/python-rpi.gpio.* /tmp/
sudo dpkg --remove --force-remove-reinstreq python-rpi.gpio
A typo in your command sudo dpkg --remove --force-remove --reinstreq isn't valide. The correct option is --force-remove-reinstreq. See dpkg --force-help.

Can't install packages like simpleHTTPServer with pip2.7

I'm trying to install a module called simpleHTTPServer but can't do so as described below:
root#kali:~# pip install simpleHTTPServer
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
ERROR: Could not find a version that satisfies the requirement simpleHTTPServer (from versions: none)
ERROR: No matching distribution found for simpleHTTPServer
root#kali:~#
I've screwed up my python2.7 a few hours ago by accidentally removing (rm) the python2.7 file in /usr/bin instead of renaming it with mv because i didn't pay attention to what i was doing. So I removed everything that had to do with python2.7. I've then managed to download python 2.7.18 from the official site and executed these commands below AS ROOT:
cd /home/johnmap007/Downloads/Python-2.7.18
./configure
make
make install
python setup.py clean
python setup.py build
python setup.py install
Then I got back up and running. pip started to work ok and python gives me the interpreter when i execute it in the cmd line. I am running Kali Linux by the way. I tried installing other packages like scapy and they worked. I don't know why i can't install this specific package. Any help would be greatly appreciated. Thanks in advance!
EDIT: For some reason, as i was running apt upgrade, i got errors about python2.7 not being configured the right way:
Setting up python2.7 (2.7.18-1) ...
/var/lib/dpkg/info/python2.7.postinst: 9: /usr/bin/python2.7: not found
dpkg: error processing package python2.7 (--configure):
installed python2.7 package post-installation script subprocess returned error exit status 127
Setting up sqlmap (1.4.11-1) ...
Installing new version of config file /etc/sqlmap/sqlmap.conf ...
Setting up libgstreamer-plugins-base1.0-0:amd64 (1.18.1-1) ...
Setting up libgstreamer-plugins-base1.0-0:i386 (1.18.1-1) ...
dpkg: dependency problems prevent configuration of python2:
python2 depends on python2.7 (>= 2.7.18~); however:
Package python2.7 is not configured yet.
dpkg: error processing package python2 (--configure):
dependency problems - leaving unconfigured
Setting up seclists (2020.4-0kali1) ...
Setting up libgstreamer-gl1.0-0:amd64 (1.18.1-1) ...
Setting up gstreamer1.0-plugins-base:amd64 (1.18.1-1) ...
Setting up gstreamer1.0-plugins-base:i386 (1.18.1-1) ...
Setting up python3-cryptography (3.2.1-1) ...
Setting up libsvn1:amd64 (1.14.0-3) ...
dpkg: dependency problems prevent configuration of python2.7-dev:
python2.7-dev depends on python2.7 (= 2.7.18-1); however:
Package python2.7 is not configured yet.
dpkg: error processing package python2.7-dev (--configure):
dependency problems - leaving unconfigured
Setting up gstreamer1.0-gl:amd64 (1.18.1-1) ...
Setting up gstreamer1.0-x:amd64 (1.18.1-1) ...
Setting up gstreamer1.0-x:i386 (1.18.1-1) ...
Setting up gstreamer1.0-alsa:amd64 (1.18.1-1) ...
dpkg: dependency problems prevent configuration of python2-dev:
python2-dev depends on python2 (= 2.7.18-2); however:
Package python2 is not configured yet.
python2-dev depends on python2.7-dev (>= 2.7.18~); however:
Package python2.7-dev is not configured yet.
dpkg: error processing package python2-dev (--configure):
dependency problems - leaving unconfigured
Setting up gir1.2-gst-plugins-base-1.0:amd64 (1.18.1-1) ...
Setting up subversion (1.14.0-3) ...
Processing triggers for kali-menu (2020.4.0) ...
Processing triggers for libc-bin (2.31-4) ...
Processing triggers for man-db (2.9.3-2) ...
Errors were encountered while processing:
python2.7
python2
python2.7-dev
python2-dev
needrestart is being skipped since dpkg has failed
E: Sub-process /usr/bin/dpkg returned an error code (1)
I have no idea what happened and i tried running dpkg --configure -a already. Can someone help me please?
That's in the standard library, so you don't need to install anything
https://docs.python.org/2/library/simplehttpserver.html
You can start it with
python -m SimpleHTTPServer
But you should use Python3, anyway, where it's renamed
python3 -m http.server
I removed everything that had to do with python2.7
You're modifying operating system files at that point, and Kali Linux uses Python for more than your own scripting purposes. But based on /usr/bin/python2.7: not found, you could start symlink-ing files around to fix at least that error

Not able to install any package on Ubuntu 14.04 LTS, seeing dpkg: error processing package

I'm trying to install Python3 package which was required to upgrade it to 16.04 LTS and then 18.04 OS. I've come across several links to solve it, but found no luck. Implemented following steps to remove and reinstall -
sudo mv /var/lib/dpkg/info/<packagename>.* /tmp/
sudo dpkg --remove --force-remove-reinstreq <packagename>
sudo apt-get remove <packagename>
sudo apt-get autoremove && sudo apt-get autoclean
However, seeing the same issues
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3-gi is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
12 not fully installed or removed.
Need to get 0 B/8666 B of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] Y
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_CTYPE = "UTF-8",
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
dpkg: error processing package python3 (--configure):
package is in a very bad inconsistent state; you should
reinstall it before attempting configuration
dpkg: dependency problems prevent configuration of python3-distupgrade:
python3-distupgrade depends on python3:any (>= 3.3.2-2~); however:
Package python3 is not configured yet.
dpkg: error processing package python3-distupgrade (--configure):
dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
.....
.....
.....
.....
.....
.....
.....
dpkg: error processing package cloud-init (--configure):
dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already
dpkg: dependency problems prevent configuration of dh-python:
dh-python depends on python3:any (>= 3.3.2-2~); however:
Package python3 is not configured yet.
dpkg: error processing package dh-python (--configure):
dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already
E: Sub-process /usr/bin/dpkg returned an error code (1)
Can anyone guide me through ??

missing _ctypes and without yum and pkg

I was trying to install python 3.7.4 on a freebsd machine.
At the end of make install the error popped out.
ModuleNotFoundError: No module named '_ctypes'
Libffi is installed by source and its prefix was set to $HOME/lib/libffi
Attempt 1. I've tried installing cpython, and it installed setuptools successfully at the end of make install. Then when I was installing numpy by source, The same error appeared.
So I deleted cpython and tried to install the regular one again.
Attempt 2. According to this thread I added the some stuffs while doing ./configure. The full command was:
./configure --enable-optimizations --prefix=$HOME/programs/python --enable-shared LDFLAGS="-L$HOME/lib" CPPFLAGS="-I $HOME/lib/libffi/lib/libffi-3.2.1/include"
but the same error popped out at the end of make install
Attempt 3. I've tried to force install an anaconda on it, but it didn't work.
Side note 1: yum and did not exist on the machine, and I don't have the root access.
Side note 2: I've deleted every -fprofile-correction in Makefile, since the machine doesn't recognize it.
Side note 3: this is found near the end of make:
Python build finished successfully!
(...)
Failed to build these modules:
_ctypes
It is almost always a mistake for a FreeBSD user to build a software package, that's already been officially ported to the OS, himself.
What you should do instead is:
cd /usr/ports/lang/python37
make install clean

/usr/local/bin/python2: No module named pip (Raspberry Pi/Jessie)

Iv'e gotten lots of help from stackoverflow but I'm stumped and this is my first post. I'm trying to install OverGrive from a .deb file and keep hitting a wall with a "/usr/local/bin/python2: No module named pip" on the installation. I'm fairly certain I've met all of the dependencies and have uninstalled and reinstalled pip both directly and through my package manager several times. There is obviously some kind of path/registry type problem but I can't resolve it. Scale of 10, my experience is 4. Thanks!
pi#raspberrypi:~/Downloads $ sudo dpkg -i overgrive_3.2.3_all.deb
(Reading database ... 136303 files and directories currently installed.)
Preparing to unpack overgrive_3.2.3_all.deb ...
/var/lib/dpkg/info/overgrive.prerm: line 5: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
Unpacking overgrive (3.2.3) over (3.2.3) ...
Setting up overgrive (3.2.3) ...
/usr/local/bin/python2: No module named pip
dpkg: error processing package overgrive (--install):
subprocess installed post-installation script returned error exit status 1
Processing triggers for desktop-file-utils (0.22-1) ...
Processing triggers for mime-support (3.58) ...
Processing triggers for libglib2.0-0:armhf (2.42.1-1) ...
Errors were encountered while processing:
overgrive
pi#raspberrypi:~/Downloads $ pip -V
pip 9.0.1 from /usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg (python 2.7)

Categories