0

I'm quite new to Ubuntu. On my machine, running Ubuntu 20.04 with Python 3.8, I'm trying to run a program which does not support Python 3.8, but it requires Python 3.7 (FYI, it is Carla Simulator).

I need pygame, but when installing it through pip (python3.7 -m pip install pygame) it raises an error: ModuleNotFoundError: No module named 'distutils.util'

Now, I have distutils correctly installed and updated at version 3.8.2-1ubuntu1. Is there any way for me to install a distutils version compatible with Python 3.7 without affecting Python 3.8 and related modules? Or do you have hany suggestion to get pygame for Python 3.7 and running Carla somehow? Could a virtual environment help?

My question is really similar to this one How to install python-distutils but I don't actually require distutils, I just need the program to work...

Thank you

----- EDIT -----

I tried creating a virtual environment using venv, but I got an error due tue unavailability of ensurepip. Googling it, I found it might be related to the fact that my Python 3.7 version might have been installed through Anaconda (I actually can't remember). Running apt-cache rdepends python3.7 I get:

python3.7
Reverse Depends:
  python3.7-minimal

Is it safe to completely uninstall current Python3.7 and reinstall it to hopefully get ensurepip? Any suggested code to safely do it?

ALai
  • 739
  • 9
  • 18

2 Answers2

1

The easiest solution for you would be to run your program in a virtual environment where you would specify the default python version to be 3.7 I think (see Use different Python version with virtualenv for an example). You can then install all your dependencies inside this environment and not have to deal with any conflicts between the two versions on Python.

Donatien
  • 151
  • 6
  • Thank you for your answer. Unfortunately, using virtualenv I get another error related to the absence of `distutils`. Using venv instead, I get another error which I've reported in my question. No problem using 3.8, but I couldn't start the venv with a different version. – ALai May 14 '20 at 15:39
1

Using pyenv you could specify the python version you want to use. for example: create a new folder and hit:

pyenv local 3.7.2

then create your virtual env by using pipenv:

pipenv install

then start your journey to building your game.

hope it help.

Phaoris
  • 121
  • 1
  • 10
  • No way I can use it. `pyenv` command cannot be found. Using `pyvenv`, instead, I get a suggestion to install it through `sudo apt install python3-venv`. Running the line, I discover it is already installed... – ALai May 14 '20 at 16:00