终端未在 Ubuntu 18.04 中启动

Terminal does not start in Ubuntu 18.04

我尝试在 Ubuntu 中安装 Django Framework。我正在使用 python 3.8。但在正常安装中,Django 1.1 已经安装。我将 python3 的替代方案更改为 python3.8 。并使用 python3 -m pip install django。我安装了 Django(v 3.3) 并使用了它。但是更改选项后,终端无法打开和启动。

我从 ubuntu 中删除了 python3.6。然后问题就开始了。

linux 运行 中的某些程序似乎在 python3.6 中删除后,

我无法解决问题,终端 windows 打不开。我尝试了其他方法(更改 gnome-terminal 文件,将备选方案更改为默认 v3.6 并修复损坏的发行版),但它们没有帮助我。我无法打开终端,当我 运行 sudo apt update 我收到这个错误:

有什么想法吗?

      File has unexpected size (1133 != 1128). Mirror sync in progress? [IP: ***.**.***.** 80]   
 Release file created at: Wed, 06 May 2020 19:27:45 +0000 Fetched 1,762 B in 2s (932 B/s)  Traceback (most recent call last):   File "/usr/lib/cnf-update-db", line 8, in <module>
        from CommandNotFound.db.creator import DbCreator   File "/usr/lib/python3/dist-packages/CommandNotFound/db/creator.py", line 7, in <module>
        import sqlite3   File "/usr/lib/python3.6/sqlite3/__init__.py", line 23, in <module>
        from sqlite3.dbapi2 import *   File "/usr/lib/python3.6/sqlite3/dbapi2.py", line 23, in <module>
        import datetime   File "/usr/lib/python3.6/datetime.py", line 8, in <module>
        import math as _math ModuleNotFoundError: No module named 'math' Error in sys.excepthook: Traceback (most recent call last):   File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
        from apport.fileutils import likely_packaged, get_recent_crashes   File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
        from apport.report import Report   File "/usr/lib/python3/dist-packages/apport/report.py", line 12, in <module>
        import subprocess, tempfile, os.path, re, pwd, grp, os, time, io   File "/usr/lib/python3.6/subprocess.py", line 136, in <module>
        import _posixsubprocess ModuleNotFoundError: No module named '_posixsubprocess'

    Original exception was: Traceback (most recent call last):   File "/usr/lib/cnf-update-db", line 8, in <module>
        from CommandNotFound.db.creator import DbCreator   File "/usr/lib/python3/dist-packages/CommandNotFound/db/creator.py", line 7, in <module>
        import sqlite3   File "/usr/lib/python3.6/sqlite3/__init__.py", line 23, in <module>
        from sqlite3.dbapi2 import *   File "/usr/lib/python3.6/sqlite3/dbapi2.py", line 23, in <module>
        import datetime   File "/usr/lib/python3.6/datetime.py", line 8, in <module>
        import math as _math ModuleNotFoundError: No module named 'math' Reading package lists... Done E: Failed to fetch http://dl.google.com/linux/chrome/deb/dists/stable/main/binary-amd64/Packages.gz File has unexpected size (1133 != 1128). Mirror sync in progress? [IP:
    * 80]    Hashes of expected file:
        - Filesize:1128 [weak]
        - SHA256:*
        - SHA1:*
        - MD5Sum:*
Release file created at: Wed, 06 May 2020 19:27:45 +0000 E: Some index files failed to download. They have been ignored, or old ones used instead. E: Problem executing scripts APT::Update::Post-Invoke-Success 'if /usr/bin/test -w /var/lib/command-not-found/ -a -e /usr/lib/cnf-update-db; then /usr/lib/cnf-update-db > /dev/null; fi' E: Sub-process returned an error code

当我尝试 运行 django-admin:

时显示以下结果
Traceback (most recent call last):
  File "/usr/bin/django-admin", line 5, in <module>
    from django.core.management import execute_from_command_line
  File "/home/pytm/.local/lib/python3.6/site-packages/django/__init__.py", line 1, in <module>
    from django.utils.version import get_version
  File "/home/pytm/.local/lib/python3.6/site-packages/django/utils/version.py", line 1, in <module>
    import datetime
  File "/usr/lib/python3.6/datetime.py", line 8, in <module>
    import math as _math
ModuleNotFoundError: No module named 'math'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
    from apport.report import Report
  File "/usr/lib/python3/dist-packages/apport/report.py", line 12, in <module>
    import subprocess, tempfile, os.path, re, pwd, grp, os, time, io
  File "/usr/lib/python3.6/subprocess.py", line 136, in <module>
    import _posixsubprocess
ModuleNotFoundError: No module named '_posixsubprocess'

Original exception was:
Traceback (most recent call last):
  File "/usr/bin/django-admin", line 5, in <module>
    from django.core.management import execute_from_command_line
  File "/home/pytm/.local/lib/python3.6/site-packages/django/__init__.py", line 1, in <module>
    from django.utils.version import get_version
  File "/home/pytm/.local/lib/python3.6/site-packages/django/utils/version.py", line 1, in <module>
    import datetime
  File "/usr/lib/python3.6/datetime.py", line 8, in <module>
    import math as _math
ModuleNotFoundError: No module named 'math'
profiling:/home/user/Downloads/Python-3.6.10/Programs/python.gcda:Cannot open
profiling:/home/user/Downloads/Python-3.6.10/Modules/xxsubtype.gcda:Cannot open

几个小时后,我找到了解决问题的方法。

首先,我备份了我的所有数据(我会向所有尝试此操作的人推荐)。尽管它对我有用,但由于某种原因它可能会在您的计算机上失败并且您不想丢失数据。

我运行以下命令删除旧版本python3.6而不删除所有依赖项并直接安装默认版本。

sudo dpkg --remove --force-depends python3.6 python3.6-minimal libpython3.6-minimal libpython3.6-stdlib
sudo apt-get install python3.6 python3.6-minimal libpython3.6-minimal libpython3.6-stdlib

我 运行 sudo apt-get updatesudo apt-get upgrade 在重新启动我的机器之前。

一切都变好了..