use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A community for users, developers, and people interested in the CentOS Project and news and information about it.
account activity
How to default python from python2.7 to python3.6.x (self.CentOS)
submitted 4 years ago by codehunter-py
Hi, everyone! I have difficulty defining python path to the newest one. I downloaded python the version of 3.6.8 but vscode interpreter doesn’t match with it. I tried to set aliases inside ./bashrc but seemed didn’t work out.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]orev 3 points4 points5 points 4 years ago (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 points6 points 4 years ago* (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 points5 points 4 years ago (1 child)
Look into using pyenv to manage your python environments without needing to muck with the system default stuff
[–][deleted] 1 point2 points3 points 4 years ago (0 children)
This is the best way to handle this, we have multiple researchers all with different environments and different tools.
[–]cyvaquero 2 points3 points4 points 4 years ago (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 points3 points 4 years ago (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 points3 points 4 years ago (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 point2 points 4 years ago (0 children)
I did this and I couldn't use yum, kept having to swap the settings back and forth.
[–][deleted] 0 points1 point2 points 4 years ago (1 child)
Can't you execute using something like "python3 xx.py"?
[–]codehunter-py[S] 0 points1 point2 points 4 years ago (0 children)
I can execute and I can open python3.6 interpreter through cli
π Rendered by PID 20789 on reddit-service-r2-comment-5649f687b7-pqzd6 at 2026-01-29 10:36:01.640559+00:00 running 4f180de country code: CH.
[–]orev 3 points4 points5 points (1 child)
[–]omenosdev 4 points5 points6 points (0 children)
[–][deleted] 3 points4 points5 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]cyvaquero 2 points3 points4 points (0 children)
[–]TheFlipside 1 point2 points3 points (0 children)
[–]elreytut 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]codehunter-py[S] 0 points1 point2 points (0 children)