1

I am trying to install virtualenv but getting the below error on ubuntu bionic

rock64@rockpro64:~$ pip3 install virtualenv virtualenvwrapper
Traceback (most recent call last):
  File "/usr/bin/pip3", line 9, in <module>
    from pip import main
  File "/usr/lib/python3/dist-packages/pip/__init__.py", line 29, in <module>
    from pip.utils import get_installed_distributions, get_prog
  File "/usr/lib/python3/dist-packages/pip/utils/__init__.py", line 23, in <module>
    from pip.locations import (
  File "/usr/lib/python3/dist-packages/pip/locations.py", line 9, in <module>
    from distutils import sysconfig
ImportError: cannot import name 'sysconfig

' But if i try install distutils i get different error:

rock64@rockpro64:~$ sudo apt --fix-broken install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
  python3-distutils python3-lib2to3
The following NEW packages will be installed:
  python3-distutils python3-lib2to3
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
2 not fully installed or removed.
Need to get 0 B/222 kB of archives.
After this operation, 3,143 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 120131 files and directories currently installed.)
Preparing to unpack .../python3-lib2to3_3.6.9-1~18.04_all.deb ...
Unpacking python3-lib2to3 (3.6.9-1~18.04) ...
dpkg: error processing archive /var/cache/apt/archives/python3-lib2to3_3.6.9-1~18.04_all.deb (--unpack):
 trying to overwrite '/usr/lib/python3.8/lib2to3/Grammar.txt', which is also in package python3.8-lib2to3 3.8.0-1+bionic2
Preparing to unpack .../python3-distutils_3.6.9-1~18.04_all.deb ...
Unpacking python3-distutils (3.6.9-1~18.04) ...
dpkg: error processing archive /var/cache/apt/archives/python3-distutils_3.6.9-1~18.04_all.deb (--unpack):
 trying to overwrite '/usr/lib/python3.8/distutils/README', which is also in package python3.8-distutils 3.8.0-1+bionic2
Errors were encountered while processing:
 /var/cache/apt/archives/python3-lib2to3_3.6.9-1~18.04_all.deb
 /var/cache/apt/archives/python3-distutils_3.6.9-1~18.04_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
  • Your post shows you are attempting to install python3-distutils_3.6.9-1~18.04_all.deb but it seems to be conflicting with the installed python3.8-distutils 3.8.0-1+bionic2. Is your Python 3.8 install from an unofficial repository? Did you happen to use the Deadsnakes PPA which has a change from last week that addresses this very problem? If not, please tell us where your Python 3.8 came from and if the official Ubuntu Python 3.8 works any better. – GracefulRestart Nov 20 '19 at 18:39
  • After installing ubuntu i was installing python 3.8 following unofficial repository you are guessing following this link https://vsupalov.com/developing-with-python3-8-on-ubuntu-18-04/ – Ciasto piekarz Nov 20 '19 at 21:23

1 Answers1

1

According to this change log notice for the latest revision of their Python 3.8 release, the maintainers of the Deadsnakes PPA acknowledged that their release conflicts with upstream Ubuntu.

First update python3.8 to the newest release or remove it entirely. You want to ensure the removal of the python3.8-distutils, python3.8-tk, python3.8-gdbm, python3.8-lib2to3 packages, after which you should no longer be conflicting with Ubuntu packages.

You should then be able to install python3-distutils from the official Ubuntu repositories, which should fix the virtualenv issue you are experiencing.