Reputation: 1
Currently when I need to use python in the terminal or run something with python I need to write "python3 ....." For example "python3 manage.py makemigrations" Is there any way I can rename it to something shorter for simplicity like "py"
Upvotes: 0
Views: 270
Reputation: 21
Like the first comment, I am also using an alias. However, if you use a dependency manager like Poetry, python
works by default when inside your virtual environment. No need to create an alias.
Setting up an alias
open ~/.zshrc
alias py=/usr/local/bin/python3.9
source ~/.zshrc
(or source your bash profile, whichever setup you
have)python
Upvotes: 0
Reputation: 253
If you using Linux or Mac. You can achieve this by using a symbolic link
First, get your python path by using
which python
Then create a symbolic link
ln -s /Users/.virtualenvs/bin/python /Users/.virtualenvs/bin/py
Hereafter just using py
will run as python
Upvotes: 0
Reputation: 191738
Sure, you can create a symlink in your PATH or alias in your terminal. Do not rename the executable itself...
But some OS prefer you use python3
since python
commonly refers to Python 2.x executable, which is end of life, but still exists as a dependency for some programs
Upvotes: 1