How to properly install python 3.10+ without breaking my system

Hello Everyone,

I am using openSUSE Leap 15.6 and want to install a newer version of python in a virtual environment without breaking my system by messing up the sysetm-installed python. I am not exactly sure, what the right approach is and how I should proceed.

If I understand this documentation correctly, I should install virtualenv first through zypper, create a virtualenv and then install python311 through the environment?

I also checked for existing threads and found this one, but it doesn’t give a clear conclusion:

I just checked for virtualenv with:

sudo zypper search virtualenv

and got this output:

S  | Name                      | Summary                            | Type
---+---------------------------+------------------------------------+------
   | python3-pytest-virtualenv | Virtualenv fixture for pytest      | Paket
   | python3-virtualenv        | Virtual Python Environment builder | Paket
   | python3-virtualenv-clone  | Script to clone virtualenvs        | Paket
   | python3-virtualenvwrapper | Enhancements to virtualenv         | Paket
   | python311-virtualenv      | Virtual Python Environment builder | Paket

However when trying to installing virtualenv, I get “no provider for ‘virtualenv’ found” (I don’t know if provider is the right term, my install is not in english).

I suppose that I have to add:
https://download.opensuse.org/repositories/devel:/languages:/python/15.6/devel:languages:python.repo

through, zypper addrepo and then zypper refresh. Is that right?

I usually installed Anaconda, but I cannot use Anaconda for this project. I also want to learn how to do this properly.

Thanks in advance for your help.

*edited because of typo

Several thoughts come to the surface for me.

  • Always post including the command. Do not split it up in portions separated by your storytelling like you did above (I just checked with … and got this output).
  • When your system is not “English”, precede a command with LANG=C, like
LANG=C zypper search virtualenv
  • Your search resulted in some package names, but you seem to try to install (take care, I say “seem” because you do NOT show the command) the package virtualenv , which is not in that list at all.

I did not knew, that this was possible, thanks for the info!
So I get:

LANG=C sudo zypper search virtualenv
Refreshing service 'NVIDIA'.
Refreshing service 'openSUSE'.
Loading repository data...
Reading installed packages...

S  | Name                      | Summary                            | Type
---+---------------------------+------------------------------------+--------
   | python3-pytest-virtualenv | Virtualenv fixture for pytest      | package
   | python3-virtualenv        | Virtual Python Environment builder | package
   | python3-virtualenv-clone  | Script to clone virtualenvs        | package
   | python3-virtualenvwrapper | Enhancements to virtualenv         | package
   | python311-virtualenv      | Virtual Python Environment builder | package

LANG=C sudo zypper install virtualenv
Refreshing service 'NVIDIA'.
Refreshing service 'openSUSE'.
Loading repository data...
Reading installed packages...
'virtualenv' not found in package names. Trying capabilities.
No provider of 'virtualenv' found.
Resolving package dependencies...
Nothing to do.

Are the packages already installed? If so, why does the zypper install command does not tell me so?

Yes, I am actually just following what is said on the other post and wanted to paste the output as information here. I am actually not sure if zypper search searches only through my installed packages or if it searches through the available repositories (including packages I have not yet installed but that are available).

There is no rpm named virtualenv, see your zypper se virtualenv

python3-virtualenv is not virtualenv…

You can install:
zypper in python3-virtualenv
or
zypper in python311-virtualenv

okay, I am sorry, I misunderstood something, on the following thread:

It is advised to the user to search for virtualenv using:

sudo zypper search virtualenv

That’s why I was doing it too!

Anyway, how do I even install virtualenv in the first place then?

see my last post.

In that search output there is a column S . When there is an i there, the package is installed. So those packages are not installed on your system.

When you want to install one or more of those package, you have to address them by name. Not, as in the search command, by just a part of their name. (maybe you should try to read some of man zypper to learn about those commands).

So, you could e.g. do

zypper in python3-virtualenv

(and it will probably draw in some dependencies).

Please note that I am not a Python user and that I have no idea about your real question. I only try to teach you some habits about posting in the forum and about the usage of zypper .

Edit: @Sauerland is a much faster typing then I am :wink:

1 Like

Okay, thank you for clearing this up. As i said, I really never did this before and have no knowledge of this.

So, now, what exactly are the repercussions on my system, and which one should I install? I want to use python311 on my system, but I want to install it in a way that it does not interact with my system-installed python (which is python 3.6.15).

I would use the python3 package, but I am not an pythonista.

The new uv option should do what you want. See BradLUG report for a brief introduction by Bernie.

1 Like

Could I theoretically create a virtual environment with python3 like this:

sudo python3 -m venv *name of my env*

then activate this virtual environment with

source *name of my env-env* /bin/activate

the problem is sill, that I would have to install python311 and python 311-pip alongside the base-python install. And I don’t know if this can result in problems.

Has anyone ever tried to install python311 and python311-pip or python310 and python310-pip alongside the base python installation and did this went well, or is there a risk of breakage?

There is zero risk by installing the different python packages provided in the official repos. As you need to call the different python versions by their name (python3, python310, python311,…), there is no risk of mixing or conflicts.

1 Like

Okay, so I can just go on and install python311 and python311-pip
and just create a virtual environment through python311 ?

I actually figured out, that python311 was already installed by default.

I proceeded to create a virtual environment with python311 and everything works as expected.

No further optimization is needed, and no breakage is at risk, as long as the user installs further python-packages in a virtual environment (hence the risk of breaking the base system).

I thought, that I had to be careful not to overwrite the system-python by installing the newer python version, but this does not seem to be an issue on OpenSUSE and I did not knew that (I also had seen several posts that were giving advice to be careful not to do that). This problem is solved.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.