I've got a couple aliases setup in my terminal session initialization shell script ~/.zshrc
alias python=/opt/homebrew/bin/python3.9
alias pip=/opt/homebrew/bin/pip3.9
These are interfering with my virtual environment workflow:
>>> cd my_project
>>> python -m venv venv
>>> source venv/bin/activate
>>> which python
python: aliased to /opt/homebrew/bin/python3.9
You can see how the virtual environment was not activated. Any suggestions on how I can work with venv
while having these aliases setup in my ~/.zshrc?
CodePudding user response:
Create a directory ~/bin
. In that directory create two links:
ln -vs /opt/homebrew/bin/python3.9 ~/bin/python
ln -vs /opt/homebrew/bin/pip3.9 ~/bin/pip
Edit your .zshrs
to include:
export PATH=~/bin:$PATH
The links will hide the normal executables. When virtualenv will be activated, the links will be hiden by the PATH set up by virtualenv.