9

I'm working on ubuntu 16.0.4 LTS and While creating a virtual environment in python 3.8 I'm getting No module named 'distutils.util'

I'm using the repository: sudo add-apt-repository ppa:deadsnakes/ppa I have tried the following but didn't work

sudo apt install python3-distutils Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package python-distutils 

I have tried the solution from this link

sudo apt install python3.8-distutils Reading package lists... Done Building dependency tree Reading state information... Done E: Unable to locate package python3.8-distutils E: Couldn't find any package by glob 'python3.8-distutils' E: Couldn't find any package by regex 'python3.8-distutils' 
5
  • afaik it's a built-in module. that is, you shouldn't need to install separately. was your Python 3.8 installation done correctly? Commented Jan 28, 2022 at 16:14
  • The linked solution is outdated. deadsnakes now supports Ubuntu 18.04 (bionic) and Ubuntu 20.04 (focal). Not Ubuntu 16.04. Commented Jan 28, 2022 at 16:38
  • @ mechanical_meat sure the python 3.8 was installed correctly Commented Jan 28, 2022 at 17:41
  • @ Phd is there another package that supports both python 3.6 and ubuntu 16 Commented Jan 28, 2022 at 17:43
  • stackoverflow.com/a/76691103/13086128 Commented Mar 30, 2024 at 6:57

1 Answer 1

17

Make sure to replace 3.10 which is version of python with appropriate version.

Installing Python3.10

Update system $ sudo apt-get update -y && sudo apt-get full-upgrade -y Helps to add ppa repositories $ sudo apt install software-properties-common -y Adding deadsnake repository $ sudo apt-add-repository ppa:deadsnakes/ppa Installing python $ sudo apt-get install python3.10 $ sudo apt-get install python3.10-dev $ sudo apt-get install python3.10-tk Add Python 3.8 & Python 3.10 to update-alternatives $ sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1 $ sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 2 Update Python 3 for point to Python 3.10 $ sudo update-alternatives --config python3 

Installing distutils.util

$ sudo apt-get install python3.10-distutils 

Still using python3.10 -m pip some_command might result in error to fix it use

$ curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10 
Sign up to request clarification or add additional context in comments.

2 Comments

this should be an accepted response /
Helped me, particularly the last instruction.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.