Issue
I am setting up fedora 31, as I am making the switch from windows, finally. I installed python2.7 via the
./configure --enable-optimizations
make altinstall
way. This descriped that we have to use altinstall
in order to not override / destroy the python interpreter the system (fedora) ships with. Everything went fine and the custom python2.7 install. It is located in /usr/local/bin/python2.7
and therefore different to system's python which is probably the one in /usr/bin/python
.
Now I wanted to install a custom python3 as well. I googled and found the quickest way would be dnf install python3 but to my surprise it returned that Package python3-3.7.5-1.fc31.x86_64 is already installed. And I cannot remember installing it (if it isn't included inside "Development Tools")
First question: Why does Fedora come with system python interpreter? What are they for? Will another python interpreter that is named exactly the same as the sys py but found earlier due to it's PATH position break things? Or is sys py just used to run some python scripts containing a shebang to the system python?
Second:
As the already is located inside /usr/bin/python3
I wondered if Fedora is also shipped with a system python3 (as python2.7 is deprecating in a few weeks) that shouldn't be touched.
If yes, I probably should compile another python3 that should be in /usr/local/bin/
like my custom python2.7. However, doc seems like it would install it in /usr/bin/
, but I don't understand what they write about the prefix.
Third question: Are there any other dependencies required to compile python3 as this mentions builddep
(zlib e.g.) but https://docs.python.org/3/using/unix.html doesnt.
Thanks
Solution
Fedora, like most other Linux distros, ships software written in a wide variety of languages, including Python. One needs a Python interpreter if one wants to run Python programs, so Fedora ships one.
Typically, the Filesystem Hierarchy Standard implies that vendors (such as Linux distros) should ship their interpreters in /usr/bin
, so dnf install python3
installs the standard Fedora python3
package, which provides /usr/bin/python3
. It's already installed because some program (possibly dnf
itself) requires it.
In general, distros specify the shebang of their scripts as an absolute path to the interpreter, not using /usr/bin/env
, so you should be fine if you choose to install a version of Python into some place like /usr/local/bin
. You may run into problems if you use scripts from other sources that do use /usr/bin/env
but expect the system interpreter.
If you're looking to find the necessary dependencies to build Python 3 on your system, the easiest way to find that is to look at the source package (in this case, the Fedora source RPM) and see what dependencies it has. Installing those dependencies should be sufficient to compile Python unless you choose to compile it with different or nonstandard options.
Answered By - bk2204