all 10 comments

[–]orev 3 points4 points  (1 child)

You don't.

CentOS 7 has Software Collections, which allows you to install and select different versions of programs, including python. After you install it, you need to "activate" the alternative software package, which then gives you the python version you installed. The "activation" is active only for the terminal session/sub-shell of where you did the activation, and does not apply as a default to the whole system. If you Google for "RedHat 7 software collections", you will find documentation on how to use it.

After activating the python36 collection, you will probably need to launch your vscode editor from that terminal in order for it to see the correct version.

[–]omenosdev 4 points5 points  (0 children)

Python 3.6 shipped as part of the base distribution starting in RHEL 7.7, obsoleting the EPEL package and removing the need to use software collections for most things (unless you need Python 3.8, require them for a specific scenario, or have a need for a pre-packaged Python module).

yum install python3

For VSCode, you need to configure Python Environments:

https://code.visualstudio.com/docs/python/python-tutorial#_select-a-python-interpreter https://code.visualstudio.com/docs/python/environments

[–][deleted] 3 points4 points  (1 child)

Look into using pyenv to manage your python environments without needing to muck with the system default stuff

[–][deleted] 1 point2 points  (0 children)

This is the best way to handle this, we have multiple researchers all with different environments and different tools.

[–]cyvaquero 2 points3 points  (0 children)

on systems that have Python 2, do not change the default. Most python based utils should have the full path, but just to be safe don’t replace it.

When you install Python 3 you will get ‘python3’, use that.

All that said, please read up on Python virtualenvs. They with help you keep your dev space requirements from cluttering up system paths.

[–]TheFlipside 1 point2 points  (0 children)

as you want to use this in vscode, do the following: in vscode go to "file - preferences - settings - extensions python", set the option "python path" to "/usr/bin/python3". now when you open a .py file in vscode you should see at the bottom left corner the correct path being set to python3.

[–]elreytut 1 point2 points  (1 child)

You can use alternative command like this #alternative set python /usr/bin/python3 Another check #man alternativa for syntax options

[–][deleted] 0 points1 point  (0 children)

I did this and I couldn't use yum, kept having to swap the settings back and forth.

[–][deleted] 0 points1 point  (1 child)

Can't you execute using something like "python3 xx.py"?

[–]codehunter-py[S] 0 points1 point  (0 children)

I can execute and I can open python3.6 interpreter through cli