Install Python 3.8 Using virtualenv in OpenSUSE Leap 15.2

Hello, all.

I just installed a fresh openSUSE Leap 15.2. After the update, the Python 3 version is 3.6.12. I need version **3.8.**x without affecting the system-installed Python version, so I’m planning to do this via virtualenv.

What is the best way to do this?

I planned on downloading Python 3.8 from THIS LINK under “Grab binary packages directly”. What I don’t know is if installing this .rpm with YaST will overwrite the baseline Python 3 installation.

If I can install this package into a dedicated place in my home directory (without messing up the baseline Python), I can proceed with the **virtualenv **setup.

Thanks in advance for your help!

The best way to do this is to use the Opensuse packages.

What does “sudo zypper search virtualenv” for you?

If it does not list virtuelenv, try adding the Python-devel repo:

zypper addrepo https://download.opensuse.org/repositories/devel:languages:python/openSUSE_Leap_15.2/devel:languages:python.repo
zypper refresh

and try again.

There is an example of how to do this in http://bradlug.co.uk/blog/2020/07/16/july-14-2020-python-venv-tasmotizer-indi where the text on the webpage was generated on a computer running Leap 15.2.

I appreciate your feedback, guys. I’ll check after work and let you know. Thanks!

Hello again. So here’s my update.
[1] The link you referenced was for for using venv (which I initially considered). The problem is that the virtual environments that venv creates are of the same version as the system installation of Python. Since I have 3.6.12 and want 3.8.x, that won’t work - hence my choice to use virtualenv.
[2] Regarding virtualenv, yes I have the option to install it from one of the default repositories. That in itself is not an issue for me, it’s the fact that virtualenv expects the desired Python version (**3.8.x **in my case) to be already installed somewhere in the computer. It then points to it when creating the virtual environments.

My problem is how to install Python 3.8 “somewhere” without messing up the default Python installation. I thought that by downloading the .rpm myself I could somehow install it in some directory of mine and proceeding. I just don’t know how (or if you can even do that with a .rpm package).

Any other thoughts? Thanks!

Which python versions do you need?

I see zypper offers python (that is 2.7), python3 (that is 3.8.9) and there is also python39, python38 and python36.
You can install these version in parallel and the run virtuelenv.

Awesome, Marel! I don’t know why I didn’t scroll down all the way. When I did a

sudo zypper search python3

, I indeed got a whole bunch of results, but missed the **python38 **results (which were few in comparison).

So I understand that if I install this package, it will exist in parallel… so I’ll try just that. Thanks a lot!

Well, that didn’t go too well for me. :expressionless: It seems like it’s trying to overwrite the existing 3.6.12 Python installation, which is what I do NOT want. Any ideas?

r0b0ty@localhost:~> sudo zypper install python38 
Loading repository data... 
Reading installed packages... 
Resolving package dependencies... 
 
Problem: python38-3.8.10-lp152.49.1.x86_64 requires python(abi) = 3.8, but this requirement cannot be provided 
  not installable providers: python38-base-3.8.10-lp152.49.1.x86_64[https-download.opensuse.org-18a47cbb] 
 Solution 1: Following actions will be done: 
  install python38-base-3.8.10-lp152.49.1.x86_64 (with vendor change) 
    openSUSE  -->  obs://build.opensuse.org/devel:languages:python 
  deinstallation of python3-dbm-3.6.12-lp152.4.17.1.x86_64 
  deinstallation of python3-curses-3.6.12-lp152.4.17.1.x86_64 
 Solution 2: do not install python38-3.8.10-lp152.49.1.x86_64 
 Solution 3: break python38-3.8.10-lp152.49.1.x86_64 by ignoring some of its dependencies 

Okay, that is not working out of the box, you are running in a problem with incompatible modules.

Only alternative then seems to install other Python versions from source.
Looks to me like also a good reason to try running a Virtual machine and have that run a different Python version but I do not have experience with that.

You can always use Anaconda to install any python version on your system.

Have a looksee here; https://www.anaconda.com/products/individual#linux , https://docs.anaconda.com/ and https://docs.anaconda.com/anaconda/install/linux/

Do not be alarmed, it’s not commercial or closed source - they simply have an enterprise offering as well. We use it at my old job to manage multiple different python versions on SUSE boxes when we need it.

I’ll try this out next, Marel. Thanks for the advice!

I love Anaconda, Miuku! And I use it regularly. Unfortunately for me, I was tasked to make this work without requiring Anaconda… so that’s my challenge. Honestly, doing this via Anaconda is my personal first choice. Thanks for your input, though!

I had a similar problem with multiple python3 versions on CentOS and i think we have solved it with pyenv. But i never used it with Leap so far. The pyenv version from the “Python Module … Leap_15.2” repository includes 3.8 support.


~> pyenv --version 
pyenv 1.2.27
~> pyenv install -list |grep 3.8 
  **3.8**.0 
  **3.8**-dev 
  **3.8**.1 
  **3.8**.2 
  **3.8**.3 
  **3.8**.4 
  **3.8**.5 
  **3.8**.6 
  **3.8**.7 
  **3.8**.8 
  **3.8**.9 
  miniconda-**3.8**.3 
  miniconda3-**3.8**.3 
  miniconda3-**3.8**-4.8.2 
  miniconda3-**3.8**-4.8.3 
  miniconda3-**3.8**-4.9.2