LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch
User Name
Password
Linux From Scratch This Forum is for the discussion of LFS.
LFS is a project that provides you with the steps necessary to build your own custom Linux system.

Notices


Reply
  Search this Thread
Old 05-19-2017, 07:51 PM   #1
jr_bob_dobbs
Member
 
Registered: Mar 2009
Distribution: Bedrock, Devuan, Slackware, Linux From Scratch, Void
Posts: 651
Blog Entries: 135

Rep: Reputation: 188Reputation: 188
two pythons


So two pythons walk into a bar ...



just kidding.

Actually, this is a serious question. I noticed that the BLFS book has instructions for installing two versions of python. When I first encountered a package that required Python, it listed either as a dependency. As I know nothing about Python, it seemed best to just use the newer one, so I picked the three version over the two version. Things went for days to weeks without a problem.

The past two days or so I've been going through the Xorg parts of the book, writing down dependencies and notes on paper, getting ready to install Xorg. Note: I've not started work on that, I'm in the planning phase.

The Mesa package lists python 2, not 3, as a dependency. Oh.

Is it possible to install 2 alongside of 3 so that the things I've already compiled that need 3 can still use it correctly?
 
Old 05-19-2017, 10:45 PM   #2
Luridis
Member
 
Registered: Mar 2014
Location: Texas
Distribution: LFS 9.0 Custom, Merged Usr, Linux 4.19.x
Posts: 616

Rep: Reputation: 167Reputation: 167
At the end for Python2, do...

make install

At the end for Python3, do...

make altinstall
cd /bin
ln -sv python3.61 python3


or ln -sv python3.6 python3, I can't remember the actual executable name ATM.

Be aware that some packages will install Python components and choose 2 or 3 based upon finding python2 or python3, usually preferring python3. However, sometimes this isn't ideal, because dependent packages, on the package that was used and built an FFI for python3, but the dependent package hasn't yet been updated to Python3. Also, if you need to install a python package dependency like say LXML for CMake (or maybe its actually libarchive), be sure to use pip2 or pip3 appropriately in these cases.

The bottom line is that not everything is Python3 ready yet and, regardless of the Python developer's arm twisting, it will be years before everything is moved over. Sometimes, in order to build a required python2 interface you must remove the python3 symlink to get that to happen. (Policy Kit, for example.) Personally, I don't install python3 until the shell is finished, though that keeps me on Gperf-3.04 & Systemd-232. (with BLFS packages)

Last edited by Luridis; 05-19-2017 at 10:54 PM.
 
Old 05-20-2017, 10:08 AM   #3
jr_bob_dobbs
Member
 
Registered: Mar 2009
Distribution: Bedrock, Devuan, Slackware, Linux From Scratch, Void
Posts: 651

Original Poster
Blog Entries: 135

Rep: Reputation: 188Reputation: 188
So I made a package for the 2 version. This way, I was then able to see what files it was putting where, yet without actually installing it and risking a trashing of anything.

piped directory listings to files, sorted them, ran "comm -12" on them.

The results were surprising. No common files. No common directories, save for /usr/share/man1 and /usr/bin. Wow. This may be because I did not install the documention. Anyway, this means that neither python will stomp on anything from the other python!

In view of that datum, I wonder if I should still do a "altinstall" rebuild/reinstall of 3?

Last edited by jr_bob_dobbs; 05-20-2017 at 10:10 AM.
 
Old 05-20-2017, 08:34 PM   #4
Luridis
Member
 
Registered: Mar 2014
Location: Texas
Distribution: LFS 9.0 Custom, Merged Usr, Linux 4.19.x
Posts: 616

Rep: Reputation: 167Reputation: 167
My recommendation was based upon what I read on the official Python website when I researched this very problem. I've run into issues using "make install" on both that using altinstall solved. In any case, programs that use Python don't seem to care how it is installed as long as it can find the python2 or python3 link when they go looking. The hardest part is remembering to use pip2 or pip3 when installing python packages needed by another program.

Last edited by Luridis; 05-20-2017 at 08:35 PM.
 
Old 05-22-2017, 12:44 PM   #5
jr_bob_dobbs
Member
 
Registered: Mar 2009
Distribution: Bedrock, Devuan, Slackware, Linux From Scratch, Void
Posts: 651

Original Poster
Blog Entries: 135

Rep: Reputation: 188Reputation: 188
I think I understand better now. Thank you.

I've since made packages for 3 and, alt 3 (same source, just using "altinstall" option). I've compared the resultant directory trees. Both have the exact same files in the same arrangement, but diff reveals many differences between the contents of those files. Aha, OK.

I've removed 3, installed 2 and then installed the altinstall version of 3. So far, no problems have emerged.

On to Xorg, I guess, once backups are done.
 
Old 05-22-2017, 02:09 PM   #6
Luridis
Member
 
Registered: Mar 2014
Location: Texas
Distribution: LFS 9.0 Custom, Merged Usr, Linux 4.19.x
Posts: 616

Rep: Reputation: 167Reputation: 167
Don't forget the python3 link to the actual executable, or programs that need 3 won't find it.
 
Old 05-22-2017, 02:11 PM   #7
Luridis
Member
 
Registered: Mar 2014
Location: Texas
Distribution: LFS 9.0 Custom, Merged Usr, Linux 4.19.x
Posts: 616

Rep: Reputation: 167Reputation: 167
Oh, and the differences inside the files are likely explicit specifications of Python3 instead of just Python.
 
Old 05-23-2017, 11:02 PM   #8
jr_bob_dobbs
Member
 
Registered: Mar 2009
Distribution: Bedrock, Devuan, Slackware, Linux From Scratch, Void
Posts: 651

Original Poster
Blog Entries: 135

Rep: Reputation: 188Reputation: 188
So this is what is in my /usr/bin directory, python-wise:
Code:
bob@artemis:~/xc/xcb-proto-1.12 $ ls -la /usr/bin/*py*
-rwxr-xr-x 1 root root  36995 May 18 22:35 /usr/bin/a2x.py
-rwxr-xr-x 1 root root 254202 May 18 22:35 /usr/bin/asciidoc.py
-rwxr-xr-x 1 root root 139520 May 14 15:35 /usr/bin/copydatabase
-rwxr-xr-x 1 root root  55635 May 15 21:39 /usr/bin/event_rpcgen.py
-rwxr-xr-x 1 root root  34941 May 16 10:49 /usr/bin/mysqlhotcopy
-rwxr-xr-x 1 root root 224312 Apr 24 22:16 /usr/bin/objcopy
-rwxr-xr-x 1 root root     78 May 20 09:47 /usr/bin/pydoc
-rwxr-xr-x 1 root root     78 May 21 08:06 /usr/bin/pydoc3.6
lrwxrwxrwx 1 root root      7 May 21 08:27 /usr/bin/python -> python2
lrwxrwxrwx 1 root root      9 May 21 08:27 /usr/bin/python2 -> python2.7
-rwxr-xr-x 1 root root   6120 May 20 09:48 /usr/bin/python2.7
-rwxr-xr-x 1 root root   1681 May 20 09:47 /usr/bin/python2.7-config
lrwxrwxrwx 1 root root     16 May 21 08:27 /usr/bin/python2-config -> python2.7-config
lrwxrwxrwx 1 root root      9 May 23 21:08 /usr/bin/python3 -> python3.6
-rwxr-xr-x 2 root root  10280 May 21 08:06 /usr/bin/python3.6
-rwxr-xr-x 2 root root  10280 May 21 08:06 /usr/bin/python3.6m
-rwxr-xr-x 1 root root   3083 May 21 08:06 /usr/bin/python3.6m-config
lrwxrwxrwx 1 root root     14 May 21 08:27 /usr/bin/python-config -> python2-config
-rwxr-xr-x 1 root root    435 May 21 08:06 /usr/bin/pyvenv-3.6
-rwxr-xr-x 1 root root  18541 May 20 09:47 /usr/bin/smtpd.py
bob@artemis:~/xc/xcb-proto-1.12 $
What concerns me is the "python" that is a symlink to python 2. Should I shift that link to python three? The reason I ask is, I just did a configure & make of a program (xcb-proto for xorg) and it was clearly linking to old python, despite a patch to make said program use python three. needless to say, I stopped at that point and did not install the program.
 
Old 05-23-2017, 11:55 PM   #9
Terry Coats
Member
 
Registered: Mar 2017
Posts: 122

Rep: Reputation: 54
I have both pythons installed and both python2 and python3 modules installed.
The book says both can exist side-by-side. I haven't had any problems. I suggest
not straying from the book. The writers know more than we do.
Don't know why the patch to python3 didn't work.

I did some work and found an answer. Here's a configure command that works:

PYTHON=/usr/bin/python3 ./configure $XORG_CONFIG

It configured ok and pulled in python3.
Anyway, test it out and see what you think.
You should still apply the patch first. It maybe necessary for this to work. I did.

Last edited by Terry Coats; 05-24-2017 at 12:24 AM. Reason: did some tests
 
  


Reply

Tags
python



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
Two Pythons's installed - Can't find wxpython doobers Linux - Software 1 04-18-2007 01:09 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Linux From Scratch

All times are GMT -5. The time now is 11:10 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