I failed again and again installing python3.8 on my ubuntu 21.04

Now it is 'ok' but this error message appears from pip (and import ctypes doesn't work too):

    Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python3.8/site-packages/setuptools/__init__.py", line 20, in <module>
    from setuptools.dist import Distribution, Feature
  File "/usr/local/lib/python3.8/site-packages/setuptools/dist.py", line 35, in <module>
    from setuptools import windows_support
  File "/usr/local/lib/python3.8/site-packages/setuptools/windows_support.py", line 2, in <module>
    import ctypes
  File "/usr/local/lib/python3.8/ctypes/__init__.py", line 7, in <module>
    from _ctypes import Union, Structure, Array
  File "/usr/local/lib/python3.8/_ctypes/__init__.py", line 8, in <module>
    from _ctypes import Union, Structure, Array
ImportError: cannot import name 'Union' from partially initialized module '_ctypes' (most likely due to a circular import) (/usr/local/lib/python3.8/_ctypes/__init__.py)
  • What is the install line exactly, normally if you say install python it will be later version, you may have to choose the 2.7/8 version
    – Keith5001
    May 6, 2021 at 21:35
  • What version do you actually want to install? The title says 2.7/2.8 but the question is actually about installing 3.8. 3.9 is the default Python version in Ubuntu 21.04, already installed, why do you need 3.8 in particular? And 2.7 can be installed just by installing the python2 package.
    – raj
    May 6, 2021 at 21:52
  • sorry, corrected. I need that version for... requirements...numpy pyqt5 pillow -- installs older pillow wich isn't compatible with 3.9!!! gym --- requires older pillow gym-retro --- requires older pillow @raj
    – france1
    May 7, 2021 at 8:49
  • 1
    Do these packages you want to install that aren't compatible with 3.9 come from default Ubuntu repositories? I think in that case you should file a bug that they aren't compatible and can't be installed properly. I guess the maintainers should provide in such a case a 3.8 package as a dependency.
    – raj
    May 7, 2021 at 9:32
  • 1
    Try it with pyenv or update-alternatives?
    – John Mee
    May 25, 2021 at 4:42

2 Answers 2


You could use the project Conda. Conda is for Python environments. Luckily you can choose the Python version you want to use. Check out at conda.io! Once you're in a Python environment, install any package by conda install PACKAGE. Official documentation: https://docs.conda.io/projects/conda/en/latest/user-guide/concepts/packages.html

To create an environment, use conda create To create a Python 3.8 environment, use the python-variable, an example: conda create -n "name" python=3.8 #quotes not required Then: conda use "name" #quotes not required


Here are to ways to install it, here is how it's done:


first update everything and install following packages

$ sudo apt update
$ sudo apt upgrade
$ sudo apt dist-upgrade
$ sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget

Next step is do make a temporary directory and download the source code of python

$ mkdir ~/tmp
$ cd ~/tmp
$ wget https://www.python.org/ftp/python/3.8.1/Python-3.8.1.tgz

next is to extract it and configure it

$ tar -xvzf Python-3.8.1.tgz
$ cd Python-3.8.1
$ ./configure

now install it with

sudo make altinstall

make sure to have sudo privileges while installing everything


Installing it with a third party PPA repo

$ sudo apt update
$ sudo apt install software-properties-common

$ sudo add-apt-repository ppa:deadsnakes/ppa

$ sudo apt update
$ sudo apt install python3.8

to finally check the version of python, execute this command.

hope that helps

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .