Hi, I have a quick question about Python on Ubuntu. By default, Ubuntu comes with Python 3 installed. However, many documentation resources still refer to Python 3 as simply "python." Given that Python 2 is no longer supported and Python 3 is the standard version, what is the best approach: Should I change the alias of python3 to python to streamline my workflow, considering that Python 2 is not widely used anymore?
#π python3 vs python (command)
13 messages Β· Page 1 of 1 (latest)
@golden osprey
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Closes after a period of inactivity, or when you send !close.
Is it still python version 2.7 if you run python --version?
I mean for convenience change the one u use to python except if its the name of the pre installed one i wouldn't mess with that
If it's 2.7, I'd probably add these lines to ~/.bashrc
alias python="python3"
alias pip="python3 -m pip"
I don't have python 2 installed , if I run "python --version" the command doesn't exist , just when I use "python3 --version" return the correct version 3.10.12
i don't have much knowledge in this, but the package description of python-is-python3 seems relevant:
Starting with the Debian 11 (bullseye) and Ubuntu 20.04 LTS (focal) releases, all python packages use explicit
python3orpython2interpreter and do not use unversioned/usr/bin/pythonat all. Some third-party code is now predominantly python3 based, yet may use/usr/bin/python.
This is a convenience package which ships a symlink to point the/usr/bin/pythoninterpreter at the current defaultpython3. It may improve compatibility with other modern systems, whilst breaking some obsolete or 3rd-party software.
there is som advantage if I use this aproach
ln -sf /usr/local/bin/python3 /usr/local/bin/python
i normally use pyenv for managing user installs of python, and it adds a python shim alongside python3
This would work for every user, including root?
yeap, but your approach of use pyenv seems like a is the best one because it will use the last version of python if I want and rename the python3 to python and the pip3 to pip
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.