5

I have installed Python 3.10 from deadsnakes on my Ubuntu 20.04 machine.

How to use it? python3 --version returns Python 3.8.10 and python3.10 -m venv venv returns error (I've installed python3-venv as well).

wjandrea
  • 28,235
  • 9
  • 60
  • 81
Omid Shojaee
  • 333
  • 1
  • 4
  • 20
  • Where did it install to? Find that directory, look in it to find the correct binary, make sure that directory is in your `$PATH`, then run it using the path and binary name. – MattDMo Nov 03 '21 at 19:21
  • have you installed `python3.10 venv` ? – grumpyp Nov 03 '21 at 19:55
  • @grumpyp I've installed ```python3-venv``` package. Not sure if it is Python3.10 or not. – Omid Shojaee Nov 03 '21 at 20:00
  • 2
    @grumpyp ```venv``` is not a Python module, so it cannot be installed by ```pip```. – Omid Shojaee Nov 04 '21 at 14:43
  • @MattDMo It should be at `/usr/bin/python3.10`. That's where mine is, though I'm using Ubuntu 18.04. And `/usr/bin` is in the default `PATH`. – wjandrea Nov 25 '21 at 22:20

2 Answers2

5

python3.10 --version will work.

python3-venv is for 3.8, so install python3.10-venv. For reference: deadsnakes packages for 3.10 for Focal.

wjandrea
  • 28,235
  • 9
  • 60
  • 81
  • This is the issue: the command to create a virtual environment is ```python3.10 -m venv *virtualenvname*```. So the ```venv``` part invokes ```python3.10-venv``` if it is installed? – Omid Shojaee Nov 27 '21 at 19:08
  • 4
    @Omid Yes, though actually `python3.10-venv` isn't its own command, it's a package that installs the `venv` module for Python 3.10. – wjandrea Nov 27 '21 at 19:10
4

So I was having the exact same problem. I figured out that I actually had to run "sudo apt-get install python3.10-full" instead of just "sudo apt-get install python3.10". I was then able to create a python3.10 virtual environment by executing "python3.10 -m venv virt".

Randy Tang
  • 103
  • 1
  • 8
  • 2
    I'm not sure we have ```apt-get install python3.10-full``` :( – Omid Shojaee Feb 13 '22 at 09:20
  • 2
    There is a kerfuffle currently around what versions of Python you can install depending on your Ubuntu version. **Deadsnakes** is a repository which allows to install Python versions not available in the standard repos. I had already added **deadsnakes** to my repo list, so that I can `apt-get install python3.10-full`, which would indeed include `python3.10-venv`. – Lenormju Feb 17 '22 at 15:54
  • 1
    Sorry @OmidShojaee. I forgot to mention after seeing @Lenormju comment. You may need to add the **deadsnakes** repository to ubuntu so that you can issue `apt-get install python3.10-full` – Randy Tang Dec 03 '22 at 15:54
  • Is there a way to go about doing this without adding the deadsnakes ppa? – fatbringer Jan 16 '23 at 06:52
  • 1
    @fatbringer i think if you have ubuntu 22.04 LTS, you should now be able to install python3.10 as it should be included in ubuntu's repos now. i could be wrong. try running 'apt-cache search python3.10' and if it's listed, then you should be able to install it without adding the deadsnakes PPA. – Randy Tang Jan 28 '23 at 02:41
  • @RandyTang ah ok my ubuntu 22.04 actually has python 3.10. But i was trying to install the python3.10 venv. – fatbringer Feb 02 '23 at 04:53
  • 1
    @fatbringer yeah as long as you have python3.10, you can create a virtual environment by issuing 'python3.10 -m venv _name_of_virt_env_' – Randy Tang Feb 03 '23 at 03:20
  • @RandyTang ok i got it. I suppose this was just recently added. Thanks so much! – fatbringer Feb 10 '23 at 03:50
  • And now I can create virtual environments with `python3.10 -m venv venv`, thanks. – Wiktor Stribiżew May 16 '23 at 10:41