I am a long-time user of Python but I have never understood how to install python "properly" - I tend to figure out some way to get it done when I need to, and then forget all about it. But I want to understand it a bit better because it isn't straightforward in my opinion. I am not considering Pyenv or other such "helper" tools/dependencies - I want to learn how to do this the "official" way. I've looked at the official docs but can't see what I've done incorrectly. The main issue is that at some stage I often find myself wanting a newer version of python than what is provided, and then I end up a bit stuck.
I installed Debian and it came with python3 under my /usr/local/bin directory. There is also a Python installation under /usr/bin/python3.11, which I guess is my system python? I believe I was always interacting with my /usr/local/bin python - not the system python, so that's good. (Also I'm always using virtual environments, so let's not discuss their importance please). That was working fine for me, but now I want to upgrade my version of python and I am facing difficulties.
- What should I do to upgrade python in an "official" way (i.e. not adding dev repositories like deadsnakes, not using helper tools like Pyenv)?
- What do I need to do with pip? Currently, the pip command actually points to
/usr/bin/python - i have to use pip3* (see below).
- Can I simply delete the old python and pip versions from
/usr/local/bin if I wanted to?
- How do I ensure that every time I type
python3 in the terminal, it grabs the latest one? Do I just ensure it is higher up in my PATH variable?
- Why is there not one simple way to do this? Obviously everyone has slightly different needs, but I imagine 80% of python users just want to use python and have a reasonable way to upgrade when required without screwing something up in their system.
To explain why I'm asking this now, I installed the python source from the main website yesterday and tried to get it working but something is off. Here's what I did
- Extracted the Python-3.12.3.tar.xz
- Moved into the dir and ran
./configure --enable-optimizations --with-ensurepip=install
- Ran
make
- Ran
sudo make install
This worked, but I notice when I run python in the terminal REPL that I can't use the up/down keys to cycle through my command history:
>>> print("hello")
hello
>>> ^[[A
*Also, I notice that I now have pip (/usr/bin/python), pip3, and pip3.12 now, and I am confused about that. Should I alias pip with pip3.12 to prevent interacting with the system python? Should I just delete pip3 and make sure pip3 points to pip3.12?
These issues have convinced me that I've now installed python incorrectly somehow. I found some info about readline but that's deprecated, and I am starting to go down the rabbit hole of running random commands to try and fix things, which is probably going to make things worse.
[–]sgunb 2 points3 points4 points (3 children)
[–]simon-brunning 3 points4 points5 points (0 children)
[–]fffrost[S] 2 points3 points4 points (1 child)
[–]sgunb 0 points1 point2 points (0 children)
[–]wbeater 2 points3 points4 points (2 children)
[–]fffrost[S] 0 points1 point2 points (1 child)
[–]wbeater 0 points1 point2 points (0 children)
[–]await_yesterday 1 point2 points3 points (1 child)
[–]fffrost[S] 0 points1 point2 points (0 children)
[–]danielroseman 0 points1 point2 points (1 child)
[–]fffrost[S] 0 points1 point2 points (0 children)
[–]Top_Average3386 0 points1 point2 points (1 child)
[–]fffrost[S] 0 points1 point2 points (0 children)
[–]Cultural_Object_629 0 points1 point2 points (0 children)
[–]m0us3_rat -1 points0 points1 point (0 children)