10

I installed Python on an openSUSE system (see version below) using the Zypper package manager. This gives me Python 3.2, but some packages require Python 3.3. Updating with zypper update python3 stays on Python 3.2. How can I upgrade to 3.3, ideally using the package manager and reusing the rest of my working Python installation (site packages, pip...)?

openSUSE 12.2 (x86_64)
VERSION = 12.2
CODENAME = Mantis
clstaudt
  • 21,436
  • 45
  • 156
  • 239

2 Answers2

9

You can add the devel:languages:python:Factory repository or use the 1 Click Install and a Python 3.3.2 version form here (e.g. from the above repo).
(Show other versions->openSUSE 12.2->Show unstable packages->1 Click Install)

To use it with zypper only (no GUI) you can add the repo as follows:

sudo zypper ar http://download.opensuse.org/repositories/devel:/languages:/python:/Factory/openSUSE_12.2/devel:languages:python:Factory.repo

Then, to use packages from that repo you should give the repo a higher priority (in this case higher priority means lower number 0=high, 100=low). To know the repo id use zypper lr and search for the repo number in the output. Then use the following command to change the priority:

 sudo zypper mr -p priority repo_number

You could use e.g. 50 as priority if your other repos have the standard priority of 99.
Then use zypper update python3 to update python.

TobiMarg
  • 3,667
  • 1
  • 20
  • 25
  • What would be the `zypper addrepo ...` command for adding the repository? – clstaudt Sep 18 '13 at 14:57
  • I should mention that I have only ssh access to the machine, no GUI. – clstaudt Sep 18 '13 at 15:11
  • Added the command to the answer (I mostly don't use zypper, but I have tried the above, so I'm quiet sure it is correct :). – TobiMarg Sep 18 '13 at 15:27
  • 1
    I have added the repository, but what is the next step? `zypper update python3` says the package is up to date (= 3.2). – clstaudt Sep 18 '13 at 16:34
  • You probably need to change the priority of the repo. I'll add the code to the answer. – TobiMarg Sep 18 '13 at 16:43
  • Probably `zypper update python3` will say (in my case) `zypper install python3-3.3.2-76.1.x86_64` then use that. – TobiMarg Sep 18 '13 at 16:54
  • This worked, but note that all previously installed python packages will be uninstalled or broken. – clstaudt Sep 18 '13 at 17:45
  • Oh. I don't know actually why that happens (why they don't have simply python 3.x as dependency), but you could try to add this `http://download.opensuse.org/repositories/devel:/languages:/python3/openSUSE_12.2/devel:languages:python3.repo` repo and see if it works. – TobiMarg Sep 18 '13 at 17:52
  • As time passes, the versions change. For OpenSuse 15.2 run `zypper addrepo --repo https://download.opensuse.org/repositories/devel:/languages:/python:/Factory/openSUSE_Leap_15.2/devel:languages:python:Factory.repo`. This will enable installing Python versions 3.8 and 3.9, but doing so will break stuff depending on factory-packaged Python 3.6. – Jari Turkia Feb 23 '21 at 11:56
  • More time has passed. I'm trying to update Python from 3.4.10 to whatever 3.6 patch (or later) is available on a SLES 12 SP5 system. The main factory now shown is . Where are relevant repositories for SLES 12? – Doug Jun 09 '23 at 01:07
5

You can follow the instructions below using pyenv:

# Step 1. Install pyenv

git clone https://github.com/pyenv/pyenv.git ~/.pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n  eval "$(pyenv init -)"\nfi' >> ~/.bashrc

# Step 2. Install missing headers for all the Python modules to be built

sudo zypper install readline-devel sqlite3-devel libbz2-devel

# Step 3. Install the desired Python version

pyenv install 3.6.3

quoting from https://gist.github.com/antivanov/01ed4eac2d7486a170be598b5a0a4ac7

Zouzias
  • 2,330
  • 1
  • 22
  • 32