DO NOT install into your global Python interpreter! ALWAYS try to use an environment when developing locally!
However, when I try setting up the venv on my Ubuntu 22.04 machine using python3 -m venv [my Exercism Python directory], I get:
The virtual environment was not created successfully because ensurepip is not
available. On Debian/Ubuntu systems, you need to install the python3-venv
package using the following command.
apt install python3.10-venv
You may need to use sudo with that command. After installing the python3-venv
package, recreate your virtual environment.
Trying to run sudo apt install python3-venv:
The following packages have unmet dependencies:
python3-venv : Depends: python3.8-venv (>= 3.8.2-1~) but it is not going to be installed
Depends: python3 (= 3.8.2-0ubuntu2) but 3.10.6-1~22.04 is to be installed
Depends: python3-distutils (>= 3.8.2-1~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
How to proceed from here? Do I even need pytest for exercism test or can I submit the code for testing, before submitting it for good?
It might still be useful to run the tests locally – if you work locally and not in the online editor–, so that you don’t need to submit each time you want to see if the tests pass.
The error you received indicates some problems with the set of packages you have installed. There could be problems with your APT source files, check your /etc/apt/sources.list or additional sources in /etc/pat/sources.list.d if you have any. You could try to run a sudo apt-get update ; sudo apt-get install -f to try to fix the broken packages, but by the look of it it probably won’t fix anything unless you found a problem in the source files above.
You might have some problems following an upgrade to 22.04, or perhaps you used some custom Python installation.
In any case, this is not the right forum, I think, for Ubuntu troubles.
You should try to search for a solution on Ubuntu forums, or ask for help there.
After applying the changes in Software & Updates, edit the sources file using sudo nano /etc/apt/sources.list (or sudo vim, if you prefer) and paste the following:
###### Ubuntu Main Repos
deb http://archive.ubuntu.com/ubuntu/ jammy main restricted universe multiverse
#deb-src http://archive.ubuntu.com/ubuntu/ jammy main restricted universe multiverse
###### Ubuntu Update Repos
deb http://archive.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ jammy-proposed main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse
#deb-src http://archive.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse
#deb-src http://archive.ubuntu.com/ubuntu/ jammy-updates main restricted universe multiverse
#deb-src http://archive.ubuntu.com/ubuntu/ jammy-proposed main restricted universe multiverse
#deb-src http://archive.ubuntu.com/ubuntu/ jammy-backports main restricted universe multiverse
###### Ubuntu Partner Repo
deb http://archive.canonical.com/ubuntu jammy partner
#deb-src http://archive.canonical.com/ubuntu jammy partner
###### Ubuntu Extras Repo
deb http://extras.ubuntu.com/ubuntu jammy main
#deb-src http://extras.ubuntu.com/ubuntu jammy main
Upgrade all packages (this might take a while): sudo apt-get upgrade
venv should now be installed; check it with: python3 -m venv -h