Where can I find my Python directory in Ubuntu

11,014

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/

Share:
11,014

Related videos on Youtube

user9371654
Author by

user9371654

Updated on September 18, 2022

Comments

  • user9371654
    user9371654 over 1 year

    I need to do the instructions below in Python in order to make my python program use my compiled OpenSSL instead of the Ubuntu shipped one:

    export LDFLAGS="-L/my/path/lib/ -L/my/path/lib64/"
    export LD_LIBRARY_PATH="/my/path/lib/:/my/path/lib64/"
    export CPPFLAGS="-I/my/path/include -I/my/path/include/openssl"
    ./configure --prefix=/my/path/
    make
    make install
    

    I am using Ubuntu 18. Where can I find python3 in Ubuntu 18? How can I make my python uses my installed OpenSSL not the OS shipped one?

    • guiverc
      guiverc almost 6 years
      whereis python3 will tell you where the python3 binaries are, along with help pages etc. but I cannot see how this will help you. The export 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), then make 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..
    • user9371654
      user9371654 almost 6 years
      @guiverc yes, I have a specific path instead of /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 type python3.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.
    • guiverc
      guiverc almost 6 years
      You should add that information to your question, so others see it. I don't use python, but do know if you make python3.6 the default, you'll have a number of things no longer work (eg. I suspect aptitude 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).
    • Elder Geek
      Elder Geek almost 6 years
      @guiverc this along with your previous comment looks like the beginnings of an answer at least to me. I would assume that one could accomplish a similar result by using an alias and a script that sets the appropriate environment variables.
    • guiverc
      guiverc almost 6 years
      Thanks @ElderGeek, however I doubt I could get beyond the beginnings...
    • Elder Geek
      Elder Geek almost 6 years
      @guirverc Ok. I'll take a stab at it.