LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-10-2018, 07:50 PM   #1
Astral Axiom
Member
 
Registered: Feb 2018
Location: Asheville, NC
Distribution: KDE Neon, Arch, Centos, Debian
Posts: 47

Rep: Reputation: Disabled
making python3.6.4 default python3


I recently installed Python 3.6.4 and when I open the terminal and run
Code:
python3
I still get python 3.5.2 but if I run
Code:
python3.6
I get python 3.6.4. I want to know how to make 3.6.4 my default python3. Here are the locations of the three versions:
Code:
$ which python
/usr/bin/python
$ which python3
/usr/bin/python3
$ which python3.6
/usr/local/bin/python3.6
Do I need to remove python3.6 and install it so that somehow it has the path
Code:
/usr/bin
instead of being in
Code:
/usr/local/bin
or can I simply move it there, or is all of that unnecessary and I can just set the default in some text file in /etc or something? here is the code I ran to install python 3.6.4:
Code:
apt install build-essential checkinstall
apt install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tar.xz
tar xvf Python-3.6.4.tar.xz
cd Python-3.6.4/
./configure
make
make altinstall
Oh right, you may want to know that I am running KDE Neon. On my laptop I run Arch and python 3.6.4 is already the default on that system and it has the path
Code:
/usr/bin
I guess it was put there by default when I installed the base system since I did not explicitly install it.
 
Old 04-10-2018, 09:24 PM   #2
JockVSJock
Senior Member
 
Registered: Jan 2004
Location: SATX
Distribution: RHEL/CentOS
Posts: 1,304
Blog Entries: 4

Rep: Reputation: 148Reputation: 148
What does the following command show?

Code:
export $PATH
Where does Python 3.6.4 live?

Code:
whereis python3.6.4
 
1 members found this post helpful.
Old 04-11-2018, 05:28 AM   #3
RockDoctor
Senior Member
 
Registered: Nov 2003
Location: Minnesota, US
Distribution: Fedora, Ubuntu, Linux Mint
Posts: 1,738

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
On my system (Fedora, so /bin is a link to /usr/bin) /usr/bin/python3 is a link to /usr/bin/python3.6. Perhaps it's as simple as changing the python3 link to point to the installed python3.6.4
 
1 members found this post helpful.
Old 04-11-2018, 08:20 AM   #4
Astral Axiom
Member
 
Registered: Feb 2018
Location: Asheville, NC
Distribution: KDE Neon, Arch, Centos, Debian
Posts: 47

Original Poster
Rep: Reputation: Disabled
Here is the ouptput:
Code:
$ export $PATH
bash: export: `/home/me/bin:/home/me/.local/bin:/usr/local/sbin

:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

:/usr/local/games:/snap/bin': not a valid identifier

$ echo $PATH
/home/me/bin:/home/me/.local/bin:/usr/local/sbin:/usr/local/bin

:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games

:/snap/bin
I have been looking at the "export" man pages a bit. Out of curiosity, what is the difference in
Code:
export $PATH
and
Code:
echo $PATH
? They seem to provide the same information, save the "not valid identifier" warning with "export" and the part at the beginning; "bash: export:". Can you enlighten me a bit as to what export is. As is often the case, the man pages are somewhat vague for beginners like me. I am working through a series of online Linux courses with Jason Cannon through Udemy, however I still have trouble interpreting some of the man pages at this point.

The interesting thing to me is that in my PATH
Code:
/usr/local/bin
comes before
Code:
/usr/bin
So why is the command not executed there first as it should be the first place the command is found when I type "python3"? Perhaps a link like you said RockDoctor, I need to see how to veiw all the links and learn how to create one where I want it then. I am guessing that would be in the "ln" man pages?
 
Old 04-11-2018, 09:35 AM   #5
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 14,880

Rep: Reputation: 4890Reputation: 4890Reputation: 4890Reputation: 4890Reputation: 4890Reputation: 4890Reputation: 4890Reputation: 4890Reputation: 4890Reputation: 4890Reputation: 4890
export PATH, there is no $
This is the main difference.
see man bash and look for export command, this is a built-in.
 
1 members found this post helpful.
Old 04-11-2018, 12:46 PM   #6
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,513

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
You just change the python3 link to point to the version you wish. But that might break more than a few things on the system. But, you can try it.
 
1 members found this post helpful.
Old 04-11-2018, 01:39 PM   #7
Astral Axiom
Member
 
Registered: Feb 2018
Location: Asheville, NC
Distribution: KDE Neon, Arch, Centos, Debian
Posts: 47

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by AwesomeMachine View Post
You just change the python3 link to point to the version you wish. But that might break more than a few things on the system. But, you can try it.
So basically, just type in
Code:
python3.6
when I wish to use python 3.6.4, which is always. I guess the safest and best solution would be to create an alias for python3 as python3.6?
 
Old 04-11-2018, 05:36 PM   #8
Astral Axiom
Member
 
Registered: Feb 2018
Location: Asheville, NC
Distribution: KDE Neon, Arch, Centos, Debian
Posts: 47

Original Poster
Rep: Reputation: Disabled
Creating an alias does not solve the issue and avoiding the typing of two extra characters is not the goal nor worth creating an alias for so I've scrapped that idea. Is there no way to simply upgrade the default python3 version to the latest stable release? It seems that there should be, and that it should be relatively straight forward. I created a virtual KDE Neon and explicitly installed Python 3.6.5 to
Code:
/usr/bin
and still the
Code:
python3
command starts Python 3.5.2, not that I thought it wouldn't just thought I'd try it.

Does anyone know if there is a way to simply upgrade the default Python3 to the latest stable version?
 
Old 04-13-2018, 08:45 PM   #9
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,513

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
You would do it likw this
Code:
$ cd /usr/bin
$ ls -al python3 #make sure it's a link and not a file
$ rm python3
$ ln -s python3 python3.6.4
 
1 members found this post helpful.
Old 04-14-2018, 01:22 AM   #10
Astral Axiom
Member
 
Registered: Feb 2018
Location: Asheville, NC
Distribution: KDE Neon, Arch, Centos, Debian
Posts: 47

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by AwesomeMachine View Post
You would do it likw this
Code:
$ cd /usr/bin
$ ls -al python3 #make sure it's a link and not a file
$ rm python3
$ ln -s python3 python3.6.4
Is that a different process than you meant when you wrote:
Quote:
You just change the python3 link to point to the version you wish. But that might break more than a few things on the system. But, you can try it.
? I created a virtual KDE Neon in my KDE Neon with Virtual-Box so that I can try things out that I am a bit nervous about to see if it works or if it breaks anything, I will have to try that there. I have already installed Python 3.6 in the virtual Neon in:
Code:
/usr/bin
So I will try this method there.

On a side note there is an interesting anomaly in the virtual Neon. In my other virtual machines (Centos, Debian) it is necessary to click in the machine to capture the mouse and keyboard and then press right cntrl to return mouse and keyboard to the system, but in the Neon virtual machine the mouse is always available to both the virtual machine and the system. It is hard to tell whether the keyboard is the same as it is available to the currently active window under normal operation. I think that is weird and thought I would share it .......any thoughts?
 
Old 04-14-2018, 03:53 AM   #11
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 14,880

Rep: Reputation: 4890Reputation: 4890Reputation: 4890Reputation: 4890Reputation: 4890Reputation: 4890Reputation: 4890Reputation: 4890Reputation: 4890Reputation: 4890Reputation: 4890
I think that should be:
ln -s python3.6.4 python3
 
1 members found this post helpful.
Old 04-14-2018, 09:32 AM   #12
Astral Axiom
Member
 
Registered: Feb 2018
Location: Asheville, NC
Distribution: KDE Neon, Arch, Centos, Debian
Posts: 47

Original Poster
Rep: Reputation: Disabled
This is straight from the ln man pages:
Code:
SYNOPSIS
       ln [OPTION]... [-T] TARGET LINK_NAME   (1st form)
       ln [OPTION]... TARGET                  (2nd form)
       ln [OPTION]... TARGET... DIRECTORY     (3rd form)
       ln [OPTION]... -t DIRECTORY TARGET...  (4th form)

DESCRIPTION
       In  the 1st form, create a link to TARGET with the name LINK_NAME.  In the 2nd form, create a link to
       TARGET in the current directory.  In the 3rd and 4th forms, create links to each TARGET in DIRECTORY.
       Create  hard links by default, symbolic links with --symbolic.  By default, each destination (name of
       new link) should not already exist.  When creating hard links,  each  TARGET  must  exist.   Symbolic
       links  can  hold arbitrary text; if later resolved, a relative link is interpreted in relation to its
       parent directory.

-t, --target-directory=DIRECTORY
 specify the DIRECTORY in which to create the links

-T, --no-target-directory
 treat LINK_NAME as a normal file always
I am still not experienced with the ln command, but I think if no options are supplied and there are 2 arguments(python3.6.4[target], python3[link name]) then 1st form would be applied. In which case, I think it would be correct that the command should be
Code:
ln -s python3.6.4 python3
If I understand correctly the "-T" option is applied when no options are supplied and using the command:
Code:
ln -s python3 python3.6.4
would be the 4th form, in which case the "-t" option and the full path to python3 would both need to be supplied, making the command:
Code:
ln -s /usr/bin/python3 python3.6.4
if I understand correctly. Which is a big if since I still have much trouble interpreting man pages at this time. It seems, if I understand correctly(once again), that it would be safer to be more explicit and use either that(4th form command above) or use the 3rd form:
Code:
ln -s python3.6.4 /usr/bin/python3
In any case you are, I believe, both saying to do:
Code:
$ cd /usr/bin
$ ls -al python3 #make sure it's a link and not a file
$ rm python3
$ whichever ln command is correct to create the python3 link
correct?
 
Old 04-14-2018, 10:07 AM   #13
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 14,880

Rep: Reputation: 4890Reputation: 4890Reputation: 4890Reputation: 4890Reputation: 4890Reputation: 4890Reputation: 4890Reputation: 4890Reputation: 4890Reputation: 4890Reputation: 4890
if you wish to play/learn ln, just create a new dir (as regular user) and try any combinations - on simple, short text files. That will not harm your system and you will understand the meaning of those options...
Post #11 should work only if you are already in /usr/bin, otherwise it will not make what you need.
The 4th form is not really applicable in your case I think.

https://www.cyberciti.biz/faq/creati...symbolic-link/
https://unix.stackexchange.com/quest...he-usage-of-ln
 
1 members found this post helpful.
Old 04-14-2018, 10:09 AM   #14
Astral Axiom
Member
 
Registered: Feb 2018
Location: Asheville, NC
Distribution: KDE Neon, Arch, Centos, Debian
Posts: 47

Original Poster
Rep: Reputation: Disabled
Ok, so some of my last post on this thread was forgetting that the suggested commands were being run from within the directory i.e.:
Code:
$ cd /usr/bin
being the first command to run, so forget all that. So, In my virtual Neon I ran this command(which I believe is in either the 3rd or 1st form):
Code:
$ ln -s /usr/bin/Python-3.6.5/python /usr/bin/python3
from my home directory after removing the was current python3 link from within the /usr/bin directory. This worked, now when I type python3 from the home directory, python3.6.5 is opened for use. I do not know if it broke anything else yet, as AwesomeMachine suggested it might. I will play around with it for a while and then let you know. Do either of you have any suggestions on what to check, what things might this have broken?

Last edited by Astral Axiom; 04-14-2018 at 10:12 AM.
 
Old 04-14-2018, 10:28 AM   #15
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 14,880

Rep: Reputation: 4890Reputation: 4890Reputation: 4890Reputation: 4890Reputation: 4890Reputation: 4890Reputation: 4890Reputation: 4890Reputation: 4890Reputation: 4890Reputation: 4890
in general there are a lot of things running with python (=python2) and python3. The installed python codes/scripts assume an installed and compatible python executable. Replacing this may cause incompatibilities. You need to know what are the differences between 3.5.2 and 3.6.4 and which code will depend on those changes. Most probably none, but maybe there is something....
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] how to start python3.6 interpreter just by typing python in terminal not python3.6 bmohanraj91 Linux - Newbie 4 05-10-2017 07:51 AM
After upgrade python3.4 to python3.5.1 , not able to install packages "request" though pip3 YOGESHAS87 Linux - Software 1 08-03-2016 10:38 PM
Python3 on Cygwin AsherM Linux - Newbie 6 09-14-2013 03:25 PM
[SOLVED] Python3.2 vs yum hpfeil Fedora 4 08-01-2012 10:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:09 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration