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).
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).
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
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).
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.
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.