Python is installed to all of our computers because it is useful framework for a variety of things .
To use the python interface from terminal just type python .
to check you python version just type python --version
to run a python script you need to type in the form :
./python_script_name.py
but very importantly it has to be executable first
chmod +x python_script_name.py
I hope it helps !
Answer from billybadass on askubuntu.comInstalling python on Linux - help?
Install python 3.11.9 on ubuntu
Getting started with Python development on a linux-system
How do I install python 2.7
Videos
Python is installed to all of our computers because it is useful framework for a variety of things .
To use the python interface from terminal just type python .
to check you python version just type python --version
to run a python script you need to type in the form :
./python_script_name.py
but very importantly it has to be executable first
chmod +x python_script_name.py
I hope it helps !
just type :
sudo apt-get install python
It will show you whether you have newest version of python or you should upgrade
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/binif I wanted to? -
How do I ensure that every time I type
python3in 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.