Newtron Malayalam
Newtron Malayalam

Reputation: 337

Missing python base packages

I have missing python3 dist files after upgrading to ubuntu focal. Such as math, subprocess, random, thread etc... I had a self-compiled python 3.8 installed on my old ubuntu bionic which I have deleted in an abnormal way(deleted directory located at /usr/local/lib/python3.8). Later I reinstalled python3 using sudo apt remove python3 && sudo apt install python3. Is there any way to get those packages back? Is it a common error happens with ubuntu focal?

The way I've compiled python 3.8 in old bionic

error while trying to install something using pip

newtron@newtron:~$ sudo pip3 install pip --upgrade
Traceback (most recent call last):
  File "/usr/local/bin/pip3", line 5, in <module>
    from pip._internal.cli.main import main
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/main.py", line 10, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
    from pip._internal.cli import cmdoptions
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/cmdoptions.py", line 24, in <module>
    from pip._internal.exceptions import CommandError
  File "/usr/lib/python3/dist-packages/pip/_internal/exceptions.py", line 10, in <module>
    from pip._vendor.six import iteritems
ModuleNotFoundError: No module named 'pip._vendor.six'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3.8/subprocess.py", line 64, in <module>
    import msvcrt
ModuleNotFoundError: No module named 'msvcrt'

During handling of the above exception, another exception occurred:

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.8/subprocess.py", line 69, in <module>
    import _posixsubprocess
ModuleNotFoundError: No module named '_posixsubprocess'

Original exception was:
Traceback (most recent call last):
  File "/usr/local/bin/pip3", line 5, in <module>
    from pip._internal.cli.main import main
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/main.py", line 10, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
    from pip._internal.cli import cmdoptions
  File "/usr/lib/python3/dist-packages/pip/_internal/cli/cmdoptions.py", line 24, in <module>
    from pip._internal.exceptions import CommandError
  File "/usr/lib/python3/dist-packages/pip/_internal/exceptions.py", line 10, in <module>
    from pip._vendor.six import iteritems
ModuleNotFoundError: No module named 'pip._vendor.six'

Upvotes: 0

Views: 3195

Answers (1)

Dextron
Dextron

Reputation: 628

You can use pip to install these python packages. If you don't have pip on your ubuntu do sudo apt install python3-pip Then in a terminal do pip install 'missing package'

Also these python packages are not missing but they do not come with python3. You must install them to your python environment using a wheel package or using pip

EDIT You could try to run this command and see if it fixes your problem:

curl -sS https://bootstrap.pypa.io/get-pip.py | sudo python3

it seems that manu Ubuntu users are having issues with pip3 and python. It seems like you cant use packages with the gloabl python as it causes some weird issues but you can use packages and pip3 just find in a virtual envrionment. You could also find more information and prehaps a better answer here: pip3 install not working - No module named 'pip._vendor.pkg_resources'

Upvotes: 1

Related Questions