According to the wiki as of Ubuntu 18.04.1 Python 2 is no longer installed by default. Python 3 has been updated to 3.6. This is the last LTS release to include Python 2 in main.
I would imagine that there are a number of ways that you could replace the included Python 3.6 with your own version. As any radical change to your system can render it inoperable, best practices indicate that the first thing you should do is backup. Once your backup is complete you can proceed to try whatever you like to solve your problem as in the worst case you can always return to where you began and start over with a new approach.
One of the ways that comes to mind is to use an alias. This is dead simple but may have unintended consequences.
Another slightly more complex possibility would be to setup a VM with an installation that you remove Python3.6 from and install your version from source on to take it's place.
A third possibility would be to setup virtual environment for python3.
Regretfully I am currently 1800 miles from home and can't currently test any of this, but hopefully it's enough to get you started. If anything in this answer is unclear, drop me a comment and I'll attempt to clarify upon my return.
Sources:
https://wiki.ubuntu.com/BionicBeaver/ReleaseNotes
What's a good back-up strategy for 1 desktop PC?
How do I create a permanent Bash alias?
How to install VirtualBox?
https://linoxide.com/linux-how-to/install-python-ubuntu/
whereis python3
will tell you where the python3 binaries are, along with help pages etc. but I cannot see how this will help you. Theexport
commands are BASH commands, then you list common commands to compile a program (configure looks at what you're running, confirms if you have what is needed for the subsequent make steps & reports if it sees errors etc), thenmake
builds or makes a program. These are common steps for program builds from the 1980s (pre-linux days). The LD in your bash variables stands for LIST-of-DIRECTORIES; but /my/path/ probably needed you to change it.. – guiverc Aug 05 '18 at 05:09/my/path/
I use/usr/local/openssl
so I have my own python compilation which is linked to my own compiled OopenSSL. Both python and OpenSSL are shipped with Ubuntu 18. The problem is when I typepython3.6
I want my own compiled python from the source not the system's one. How to do this? I can not move the python program file inside the python source to use./python mycode.py
because the python code is complex and writes to many files and paths there. I need to type python as normal but run my compiled version of python. – user9371654 Aug 05 '18 at 05:19aptitude
and package-management tools will stop) as some of those tools use python (which is why python 2.7 is still the default!), and thus it's a bad idea. If you really want to make changes like that, I'd expect running it in a container, or snapping the program would be a better suggestion (thus it can have it's independent environment not affecting you system-wide). – guiverc Aug 05 '18 at 06:10