
Recentemente instalei o python 3.5 da fonte, mas acho que fiz algo errado durante a instalação ou vinculação. Depois disso, tenho problemas para instalar qualquer pacote do Ubuntu. Por exemplo, add-apt-repository não funciona, mesmo depois de reinstalar o software-properties-common.
$ add-apt-repository
bash: /usr/bin/add-apt-repository: /usr/bin/python3: bad interpreter: No such file or directory
Além disso, apt-get install me dará esses erros
$ sudo apt-get install libraw-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
libraw-dev
0 upgraded, 1 newly installed, 0 to remove and 229 not upgraded.
3 not fully installed or removed.
Need to get 382 kB/391 kB of archives.
After this operation, 1,588 kB of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu/ trusty/main libraw-dev amd64 0.15.4-1 [382 kB]
Fetched 382 kB in 0s (651 kB/s)
Selecting previously unselected package libraw-dev:amd64.
(Reading database ... 295477 files and directories currently installed.)
Preparing to unpack .../libraw-dev_0.15.4-1_amd64.deb ...
Unpacking libraw-dev:amd64 (0.15.4-1) ...
Setting up python3.4 (3.4.3-1ubuntu1~14.04.5) ...
Could not find platform independent libraries <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 (--configure):
subprocess installed post-installation script returned error exit status 134
Setting up python3-commandnotfound (0.3ubuntu12) ...
/var/lib/dpkg/info/python3-commandnotfound.postinst: 6: /var/lib/dpkg/info/python3-commandnotfound.postinst: py3compile: not found
dpkg: error processing package python3-commandnotfound (--configure):
subprocess installed post-installation script returned error exit status 127
dpkg: error processing package software-properties-common (--configure):
package is in a very bad inconsistent state; you should
reinstall it before attempting configuration
Setting up libraw-dev:amd64 (0.15.4-1) ...
Errors were encountered while processing:
python3.4
python3-commandnotfound
software-properties-common
E: Sub-process /usr/bin/dpkg returned an error code (1)
Além disso, tentar adicionar ppa dá o seguinte erro
$ sudo add-apt-repository ppa:dhor/myway
sudo: unable to execute /usr/bin/add-apt-repository: No such file or directory
O que está acontecendo, alguma ideia?
Responder1
Primeiro, você precisa restaurar o núcleo do Python 3:
sudo apt install -f --reinstall python3 python3.4 python3-minimal python3.4-minimal libpython3.4-minimal
Se isso não funcionar devido a pacotes parcialmente instalados dependendo do Python 3, baixe e instale-os manualmente:
cd /tmp apt-get download python3 python3.4 python3-minimal python3.4-minimal libpython3.4-minimal sudo dpkg -i *python3*.deb sudo apt install -f
Instale o
debsums
pacote e execute umverificação de integridade do pacotepara verificar a integridade dos pacotes restantes e reinstalá-los se necessário.
Responder2
O Ubuntu vem com suas próprias instalações de Python, das quais depende para que os utilitários do sistema funcionem. Esses utilitários dependem de python
, python2
e python3
apontando para essas instalações do sistema. Infelizmente, ao construir/instalar o Python a partir do código-fonte, o padrão make install
instala novos binários python
/ python2
(para Python 2.x) ou python3
(para Python 3.x), o que pode acabar ofuscando as instalações do sistema Python e quebrando coisas.
Depois de consertar seu sistema (esperamos que a resposta de David ajude você a fazer isso), seu Python compilado a partir da fonte deve ser (re)instalado com make altinstall
, que renunciará python3
e instalará o interpretador apenas como o específico da versão python3.5
. Esta é a maneira segura de instalar seu próprio Python sem interferir nos Pythons do sistema, pois não ocultará nenhum dos comandos utilizados pelos utilitários do sistema.