skip to Main Content

I want to switch my python version from 3.9.6 to 3.10 in paperspace. But it doesn’t work.
So I need your help.

device info

$root@nu1mmmnfz5:/notebooks/LoRA# cat /etc/*release

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.5 LTS"
NAME="Ubuntu"
VERSION="20.04.5 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.5 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
$root@nu1mmmnfz5:/notebooks/LoRA# which python

/usr/local/bin/python
$root@nu1mmmnfz5:/notebooks/LoRA# ls /usr/local/bin/ | grep python

ipython
ipython3
python
python3
$ apt -y install python3.10

これが上手く入らないので苦戦しておりました。

$ python -V
Python 3.9.16
$ which python
/usr/local/bin/python

$ which python3
/usr/local/bin/python3
 $ which python3.10
/usr/bin/python3.10

There are two, ‘usr/local/bin’ and ‘usr/bin’, and ‘apt -y install python3.10’ has gone into ‘usr/bin’.

Tried

$apt update -y
$apt upgrade -y
$apt -y install python3.10

update-alternatives
enter image description here

3

Answers


  1. You can install pyenv and you will be able to switch versions at will.
    https://github.com/pyenv/pyenv

    Login or Signup to reply.
  2. you can use update-alternatives to control python version
    https://linuxconfig.org/how-to-change-from-default-to-alternative-python-version-on-debian-linux
    maybe you should set the priority 0 or the same number
    sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.11 0

    sudo update-alternatives --config  python
    [sudo] password for wz: 
    There are 2 choices for the alternative python (providing /usr/bin/python).
    
      Selection    Path                 Priority   Status
    ------------------------------------------------------------
      0            /usr/bin/python3.11   0         auto mode
      1            /usr/bin/python2.7    0         manual mode
    * 2            /usr/bin/python3.11   0         manual mode
    
    Press <enter> to keep the current choice[*], or type selection number: 1
    update-alternatives: using /usr/bin/python2.7 to provide /usr/bin/python (python) in manual mode
    
    
    Login or Signup to reply.
  3. the best practice is not to change the system python version manually since many system services depend on it.

    Also you should not install personal package using pip with root privilige for the same reason unless you know what it does.

    you can use a version management to control the python env list like pyenv or conda

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search