raspdroid
Posts: 1619
Joined: Thu Nov 06, 2014 9:15 am
Location: Gran Canaria :: España

Fatal Python error: Py_Initialize:

Mon Jan 30, 2017 9:36 am

Hola,

Desinstalé python y ahora no puedo instalar nada.

Code: Select all

root@raspberrypi:~# apt-get install attic
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 attic : Depends: python3 (>= 3.4~) but it is not going to be installed
         Depends: python3 (< 3.5) but it is not going to be installed
         Depends: libjs-sphinxdoc (>= 1.0) but it is not going to be installed
         Depends: python3-msgpack (>= 0.1.10) but it is not going to be installed
         Recommends: python3-llfuse but it is not going to be installed
 python-minimal : Depends: python2.7-minimal (>= 2.7.13-1~) but it is not going to be installed
                  Recommends: python but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).
apt --fix-broken install
Reading package lists... Done
Building dependency tree
Reading state information... Done
Correcting dependencies... Done
The following packages were automatically installed and are no longer required:
distro-info-data iso-codes libpython-stdlib libpython2.7-minimal libpython2.7-stdlib libpython3-stdlib librsync1
Use 'apt autoremove' to remove them.
The following packages will be REMOVED:
python-minimal
0 upgraded, 0 newly installed, 1 to remove and 43 not upgraded.
2 not fully installed or removed.
After this operation, 148 kB disk space will be freed.
Do you want to continue? [Y/n]
(Reading database ... 38496 files and directories currently installed.)
Removing python-minimal (2.7.13-1) ...
/var/lib/dpkg/info/python-minimal.prerm: 4: /var/lib/dpkg/info/python-minimal.prerm: find: not found
dpkg: error processing package python-minimal (--remove):
subprocess installed pre-removal script returned error exit status 127
Errors were encountered while processing:
python-minimal
E: Sub-process /usr/bin/dpkg returned an error code (1)
root@raspberrypi:~# apt-get autoremove
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
python-minimal : Depends: python2.7-minimal (>= 2.7.13-1~) but it is not installed
Recommends: python but it is not installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

¿Qué puedo hacer para arreglarlo? Ya he probado todo lo que me recomienda o lo que he encontrado por google pero nada.

Saludos

User avatar
lmarmisa
Posts: 1268
Joined: Thu Feb 14, 2013 2:22 am
Location: Jávea, Spain

Re: Fatal Python error: Py_Initialize:

Mon Jan 30, 2017 9:44 am

Intenta este comando a ver si hay suerte:

Code: Select all

sudo rm -r /var/lib/apt/
Luego haz una actualización completa:

Code: Select all

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo apt-get autoremove
sudo apt-get clean
Si quieres actualizar el kernel a la última versión, teclea:

Code: Select all

sudo rpi-update

raspdroid
Posts: 1619
Joined: Thu Nov 06, 2014 9:15 am
Location: Gran Canaria :: España

Re: Fatal Python error: Py_Initialize:

Mon Jan 30, 2017 10:24 am

Muchas gracias,

Ya probé pero sigue saliendo esto:
Reading package lists... Done
Building dependency tree... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
python-minimal : Depends: python2.7-minimal (>= 2.7.13-1~) but it is not installed
Recommends: python but it is not installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

User avatar
lmarmisa
Posts: 1268
Joined: Thu Feb 14, 2013 2:22 am
Location: Jávea, Spain

Re: Fatal Python error: Py_Initialize:

Mon Jan 30, 2017 10:54 am

También puedes borrar la cache de apt:

Code: Select all

sudo rm -r /var/cache/apt/
Luego intenta estos comandos:

Code: Select all

sudo dpkg --configure -a
sudo apt-get install -f
sudo apt-get install --reinstall python-minimal python2.7-minimal

raspdroid
Posts: 1619
Joined: Thu Nov 06, 2014 9:15 am
Location: Gran Canaria :: España

Re: Fatal Python error: Py_Initialize:

Mon Jan 30, 2017 11:01 am

Gracias pero no hay suerte.

Borré la caché.

Code: Select all

sudo dpkg --configure -a
Setting up python3.4-minimal (3.4.2-1) ...
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Aborted
dpkg: error processing package python3.4-minimal (--configure):
 subprocess installed post-installation script returned error exit status 134
Errors were encountered while processing:
 python3.4-minimal

Code: Select all

apt-get install -f
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following packages will be REMOVED:
  python-minimal
0 upgraded, 0 newly installed, 1 to remove and 43 not upgraded.
2 not fully installed or removed.
After this operation, 148 kB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 38496 files and directories currently installed.)
Removing python-minimal (2.7.13-1) ...
/var/lib/dpkg/info/python-minimal.prerm: 4: /var/lib/dpkg/info/python-minimal.prerm: find: not found
dpkg: error processing package python-minimal (--remove):
 subprocess installed pre-removal script returned error exit status 127
Errors were encountered while processing:
 python-minimal
E: Sub-process /usr/bin/dpkg returned an error code (1)

Code: Select all

sudo apt-get install --reinstall python-minimal python2.7-minimal
Reading package lists... 1%
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 python-minimal : Depends: python2.7-minimal (>= 2.7.13-1~) but 2.7.9-2+deb8u1 is to be installed
                  Recommends: python but it is not going to be installed
 python2.7-minimal : Depends: libpython2.7-minimal (= 2.7.9-2+deb8u1) but 2.7.13-1 is to be installed
                     Recommends: python2.7 but it is not going to be installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

User avatar
lmarmisa
Posts: 1268
Joined: Thu Feb 14, 2013 2:22 am
Location: Jávea, Spain

Re: Fatal Python error: Py_Initialize:

Mon Jan 30, 2017 11:42 am

Intenta bajarte los dos paquetes que faltan para satisfacer las dependencias:

Code: Select all

apt-get download libpython2.7-minimal python2.7-minimal   #no hace falta sudo!
Puedes ver que se han descargado los paquetes fácilmente:

Code: Select all

ls -l *deb
Y luego intenta instalarlos manualmente (primero la librería):

Code: Select all

sudo dpkg -i libpython2.7-minimal_2.7.9-2+deb8u1_armhf.deb
sudo dpkg -i python2.7-minimal_2.7.9-2+deb8u1_armhf.deb

raspdroid
Posts: 1619
Joined: Thu Nov 06, 2014 9:15 am
Location: Gran Canaria :: España

Re: Fatal Python error: Py_Initialize:

Mon Jan 30, 2017 11:56 am

Eso ya lo había intentado pero ya creo que sé por qué es, porque esas versiones son posteriores a la que tenía instalada porque lo había instalado desde stretch.

en /etc/apt/sources.list tengo habilitado el repositorio de stretch.

Estoy probando así pero también tengo errores:

Code: Select all

sudo apt-get install -t stretch --reinstall python2.7-minimal python3-minimal python3.4-minimal python-minimal python3.5-minimal -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libpython3.4-minimal libpython3.4-stdlib python3.4 python3.5
Suggested packages:
python3.4-venv python3.4-doc binfmt-support python3.5-venv python3.5-doc
The following NEW packages will be installed:
python3.5 python3.5-minimal
The following packages will be upgraded:
libpython3.4-minimal libpython3.4-stdlib python3-minimal python3.4 python3.4-minimal
5 upgraded, 2 newly installed, 2 reinstalled, 0 to remove and 66 not upgraded.
3 not fully installed or removed.
Need to get 40.5 kB/5,793 kB of archives.
After this operation, 12.5 MB of additional disk space will be used.
Get:1 http://ftp.cica.es/mirrors/Linux/raspbian/raspbian stretch/main armhf python-minimal armhf 2.7.13-1 [40.5 kB]
Fetched 40.5 kB in 40s (990 B/s)
E: Internal Error, No file name for python2.7-minimal:armhf

raspdroid
Posts: 1619
Joined: Thu Nov 06, 2014 9:15 am
Location: Gran Canaria :: España

Re: Fatal Python error: Py_Initialize:

Mon Jan 30, 2017 12:00 pm

También estoy intentando eliminar todo lo que hay de python pero no me deja porque dice que me faltan unos archivos
apt-get purge --remove -t stretch python-minimal python3.4 python3-minimal
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED:
python-minimal* python3-minimal* python3.4*
0 upgraded, 0 newly installed, 3 to remove and 69 not upgraded.
3 not fully installed or removed.
After this operation, 513 kB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 38526 files and directories currently installed.)
Removing python3-minimal (3.4.2-2) ...
Removing python-minimal (2.7.13-1) ...
/var/lib/dpkg/info/python-minimal.prerm: 4: /var/lib/dpkg/info/python-minimal.prerm: find: not found
dpkg: error processing package python-minimal (--remove):
subprocess installed pre-removal script returned error exit status 127
Removing python3.4 (3.4.2-1) ...
/var/lib/dpkg/info/python3.4.prerm: 11: /var/lib/dpkg/info/python3.4.prerm: xargs: not found
/var/lib/dpkg/info/python3.4.prerm: 13: /var/lib/dpkg/info/python3.4.prerm: find: not found
/var/lib/dpkg/info/python3.4.prerm: 14: /var/lib/dpkg/info/python3.4.prerm: xargs: not found
dpkg: error processing package python3.4 (--remove):
subprocess installed pre-removal script returned error exit status 127
Errors were encountered while processing:
python-minimal
python3.4
E: Sub-process /usr/bin/dpkg returned an error code (1)

User avatar
lmarmisa
Posts: 1268
Joined: Thu Feb 14, 2013 2:22 am
Location: Jávea, Spain

Re: Fatal Python error: Py_Initialize:

Mon Jan 30, 2017 12:12 pm

Para que se actualice la base de datos de paquetes ante cualquier cambio de la configuración conviene hacer un update:

Code: Select all

sudo apt-get update
Para saber lo que tienes instalado puedes usar este comando:

Code: Select all

dpkg -l

raspdroid
Posts: 1619
Joined: Thu Nov 06, 2014 9:15 am
Location: Gran Canaria :: España

Re: Fatal Python error: Py_Initialize:

Mon Jan 30, 2017 12:23 pm

Si eso se lo hago siempre y no da errores lo que si lo hace es el upgraded
Extracting templates from packages: 100%
Preconfiguring packages ...
(Reading database ... 38651 files and directories currently installed.)
Preparing to unpack .../coreutils_8.26-2_armhf.deb ...
Unpacking coreutils (8.26-2) over (8.26-1) ...
Setting up coreutils (8.26-2) ...
(Reading database ... 38651 files and directories currently installed.)
Preparing to unpack .../init-system-helpers_1.47_all.deb ...
Unpacking init-system-helpers (1.47) over (1.46) ...
Setting up init-system-helpers (1.47) ...
(Reading database ... 38651 files and directories currently installed.)
Preparing to unpack .../archives/init_1.47_armhf.deb ...
Unpacking init (1.47) over (1.46) ...
Setting up init (1.47) ...
(Reading database ... 38651 files and directories currently installed.)
Preparing to unpack .../libdebconfclient0_0.220_armhf.deb ...
Unpacking libdebconfclient0:armhf (0.220) over (0.219) ...
Setting up libdebconfclient0:armhf (0.220) ...
(Reading database ... 38651 files and directories currently installed.)
Preparing to unpack .../base-passwd_3.5.43_armhf.deb ...
Unpacking base-passwd (3.5.43) over (3.5.42) ...
Setting up base-passwd (3.5.43) ...
(Reading database ... 38651 files and directories currently installed.)
Preparing to unpack .../libapt-pkg5.0_1.4~beta4_armhf.deb ...
Unpacking libapt-pkg5.0:armhf (1.4~beta4) over (1.4~beta3) ...
Setting up libapt-pkg5.0:armhf (1.4~beta4) ...
(Reading database ... 38651 files and directories currently installed.)
Preparing to unpack .../libapt-inst2.0_1.4~beta4_armhf.deb ...
Unpacking libapt-inst2.0:armhf (1.4~beta4) over (1.4~beta3) ...
Preparing to unpack .../apt_1.4~beta4_armhf.deb ...
Unpacking apt (1.4~beta4) over (1.4~beta3) ...
Setting up apt (1.4~beta4) ...
(Reading database ... 38651 files and directories currently installed.)
Preparing to unpack .../apt-utils_1.4~beta4_armhf.deb ...
Unpacking apt-utils (1.4~beta4) over (1.4~beta3) ...
Preparing to unpack .../libudev1_232-14_armhf.deb ...
Unpacking libudev1:armhf (232-14) over (232-8) ...
Setting up libudev1:armhf (232-14) ...
(Reading database ... 38651 files and directories currently installed.)
Preparing to unpack .../archives/udev_232-14_armhf.deb ...
Unpacking udev (232-14) over (232-8) ...
Preparing to unpack .../libpam-systemd_232-14_armhf.deb ...
Unpacking libpam-systemd:armhf (232-14) over (232-8) ...
Preparing to unpack .../libsystemd0_232-14_armhf.deb ...
Unpacking libsystemd0:armhf (232-14) over (232-8) ...
Setting up libsystemd0:armhf (232-14) ...
(Reading database ... 38651 files and directories currently installed.)
Preparing to unpack .../systemd_232-14_armhf.deb ...
Unpacking systemd (232-14) over (232-8) ...
Setting up systemd (232-14) ...
addgroup: The group `systemd-journal' already exists as a system group. Exiting.
(Reading database ... 38651 files and directories currently installed.)
Preparing to unpack .../systemd-sysv_232-14_armhf.deb ...
Unpacking systemd-sysv (232-14) over (232-8) ...
Setting up systemd-sysv (232-14) ...
(Reading database ... 38651 files and directories currently installed.)
Preparing to unpack .../libgcrypt20_1.7.5-3_armhf.deb ...
Unpacking libgcrypt20:armhf (1.7.5-3) over (1.7.5-2) ...
Setting up libgcrypt20:armhf (1.7.5-3) ...
(Reading database ... 38651 files and directories currently installed.)
Preparing to unpack .../00-libssl1.0.0_1.0.1t-1+deb8u6_armhf.deb ...
Unpacking libssl1.0.0:armhf (1.0.1t-1+deb8u6) over (1.0.1t-1+deb8u5) ...
Preparing to unpack .../01-liblockfile-bin_1.14-1_armhf.deb ...
Unpacking liblockfile-bin (1.14-1) over (1.13-1) ...
Preparing to unpack .../02-liblockfile1_1.14-1_armhf.deb ...
Unpacking liblockfile1:armhf (1.14-1) over (1.13-1) ...
Preparing to unpack .../03-console-setup-linux_1.158_all.deb ...
Unpacking console-setup-linux (1.158) over (1.156) ...
Preparing to unpack .../04-console-setup_1.158_all.deb ...
Unpacking console-setup (1.158) over (1.156) ...
Preparing to unpack .../05-keyboard-configuration_1.158_all.deb ...
Unpacking keyboard-configuration (1.158) over (1.156) ...
Preparing to unpack .../06-libpng12-dev_1.2.50-2+deb8u3_armhf.deb ...
Unpacking libpng12-dev:armhf (1.2.50-2+deb8u3) over (1.2.50-2+deb8u2) ...
Preparing to unpack .../07-libpng12-0_1.2.50-2+deb8u3_armhf.deb ...
Unpacking libpng12-0:armhf (1.2.50-2+deb8u3) over (1.2.50-2+deb8u2) ...
Preparing to unpack .../08-isc-dhcp-client_4.3.5-3_armhf.deb ...
Unpacking isc-dhcp-client (4.3.5-3) over (4.3.5-1) ...
Preparing to unpack .../09-isc-dhcp-common_4.3.5-3_armhf.deb ...
Unpacking isc-dhcp-common (4.3.5-3) over (4.3.5-1) ...
Preparing to unpack .../10-libssl1.0.2_1.0.2j-5_armhf.deb ...
Unpacking libssl1.0.2:armhf (1.0.2j-5) over (1.0.2j-4) ...
Preparing to unpack .../11-rsyslog_8.24.0-1_armhf.deb ...
Unpacking rsyslog (8.24.0-1) over (8.23.0-2) ...
Preparing to unpack .../12-xxd_2%3a8.0.0197-1_armhf.deb ...
Unpacking xxd (2:8.0.0197-1) over (2:8.0.0134-1) ...
Preparing to unpack .../13-vim-tiny_2%3a8.0.0197-1_armhf.deb ...
Unpacking vim-tiny (2:8.0.0197-1) over (2:8.0.0134-1) ...
Preparing to unpack .../14-vim-common_2%3a8.0.0197-1_all.deb ...
Unpacking vim-common (2:8.0.0197-1) over (2:8.0.0134-1) ...
Preparing to unpack .../15-libedit2_3.1-20160903-3_armhf.deb ...
Unpacking libedit2:armhf (3.1-20160903-3) over (3.1-20160903-2) ...
Preparing to unpack .../16-libtasn1-6_4.10-1_armhf.deb ...
Unpacking libtasn1-6:armhf (4.10-1) over (4.9-4) ...
Preparing to unpack .../17-crda_3.18-1_armhf.deb ...
Unpacking crda (3.18-1) over (3.13-1+b1) ...
Preparing to unpack .../18-distro-info-data_0.33_all.deb ...
Unpacking distro-info-data (0.33) over (0.32) ...
Preparing to unpack .../19-libfakeroot_1.21-3.1_armhf.deb ...
Unpacking libfakeroot:armhf (1.21-3.1) over (1.21-3) ...
Preparing to unpack .../20-fakeroot_1.21-3.1_armhf.deb ...
Unpacking fakeroot (1.21-3.1) over (1.21-3) ...
Preparing to unpack .../21-iso-codes_3.74-1_all.deb ...
Unpacking iso-codes (3.74-1) over (3.73-1) ...
Preparing to unpack .../22-libfcgi-perl_0.77-1+deb8u1_armhf.deb ...
Unpacking libfcgi-perl (0.77-1+deb8u1) over (0.77-1+b1) ...
Preparing to unpack .../23-mariadb-client_10.0.29-0+deb8u1_all.deb ...
Unpacking mariadb-client (10.0.29-0+deb8u1) over (10.0.28-0+deb8u1) ...
Preparing to unpack .../24-mariadb-server_10.0.29-0+deb8u1_all.deb ...
Unpacking mariadb-server (10.0.29-0+deb8u1) over (10.0.28-0+deb8u1) ...
Setting up libedit2:armhf (3.1-20160903-3) ...
Setting up libapt-inst2.0:armhf (1.4~beta4) ...
Setting up keyboard-configuration (1.158) ...
Setting up liblockfile-bin (1.14-1) ...
Setting up python3.4-minimal (3.4.2-1) ...
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ImportError: No module named 'encodings'
Aborted
dpkg: error processing package python3.4-minimal (--configure):
subprocess installed post-installation script returned error exit status 134
Setting up libpam-systemd:armhf (232-14) ...
Setting up libssl1.0.0:armhf (1.0.1t-1+deb8u6) ...
Processing triggers for mime-support (3.60) ...
Setting up xxd (2:8.0.0197-1) ...
Setting up iso-codes (3.74-1) ...
Setting up isc-dhcp-common (4.3.5-3) ...
Setting up apt-utils (1.4~beta4) ...
Processing triggers for install-info (6.3.0.dfsg.1-1+b1) ...
Setting up crda (3.18-1) ...
Setting up liblockfile1:armhf (1.14-1) ...
Setting up mariadb-client (10.0.29-0+deb8u1) ...
Setting up distro-info-data (0.33) ...
Processing triggers for sgml-base (1.29) ...
Setting up libpng12-0:armhf (1.2.50-2+deb8u3) ...
Setting up libtasn1-6:armhf (4.10-1) ...
Setting up isc-dhcp-client (4.3.5-3) ...
Setting up libssl1.0.2:armhf (1.0.2j-5) ...
Processing triggers for libc-bin (2.24-8+rpi1) ...
Setting up udev (232-14) ...
addgroup: The group `input' already exists as a system group. Exiting.
update-initramfs: deferring update (trigger activated)
Setting up libfakeroot:armhf (1.21-3.1) ...
Processing triggers for systemd (232-14) ...
Setting up vim-common (2:8.0.0197-1) ...
Setting up libpng12-dev:armhf (1.2.50-2+deb8u3) ...
Processing triggers for man-db (2.7.6.1-2) ...
Setting up mariadb-server (10.0.29-0+deb8u1) ...
Processing triggers for dbus (1.10.14-1) ...
Setting up console-setup-linux (1.158) ...
Setting up libfcgi-perl (0.77-1+deb8u1) ...
Setting up rsyslog (8.24.0-1) ...
Installing new version of config file /etc/init.d/rsyslog ...
Setting up python2.7-minimal (2.7.13-1) ...
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
python2.7: can't open file '/usr/lib/python2.7/py_compile.py': [Errno 2] No such file or directory
dpkg: error processing package python2.7-minimal (--configure):
subprocess installed post-installation script returned error exit status 2
Setting up vim-tiny (2:8.0.0197-1) ...
Setting up console-setup (1.158) ...
Setting up fakeroot (1.21-3.1) ...
dpkg: dependency problems prevent configuration of python-minimal:
python-minimal depends on python2.7-minimal (>= 2.7.13-1~); however:
Package python2.7-minimal is not configured yet.

dpkg: error processing package python-minimal (--configure):
dependency problems - leaving unconfigured
Processing triggers for initramfs-tools (0.126) ...
Processing triggers for libc-bin (2.24-8+rpi1) ...
Processing triggers for systemd (232-14) ...
Errors were encountered while processing:
python3.4-minimal
python2.7-minimal
python-minimal
E: Sub-process /usr/bin/dpkg returned an error code (1)
El asunto es que es el servidor de base de datos y no me está funcionando , está parado y tampoco sé como extraer las bases de datos sino no está funcionando mysql.

raspdroid
Posts: 1619
Joined: Thu Nov 06, 2014 9:15 am
Location: Gran Canaria :: España

Re: Fatal Python error: Py_Initialize:

Mon Jan 30, 2017 8:51 pm

Al final restauré una copia porque no pude arreglarlo. Gracias por la ayuda.

Return to “Español”