Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

303
Visualizações
Python symlink to python3

So I'm setting up my default variables in a new MacBook M1 and for some reason, my symlink doesn't seem to work.

Why is the following behaviour happening? The symlink from python to python3 gets lost somehow. /Users/overflow/Documents/tools is part of my PATH variable.

$ type python
python is /Users/overflow/Documents/tools/python

$ python -V
Python 2.7.16

$ ls -lah /Users/overflow/Documents/tools/python
lrwxr-xr-x  1 overflow  staff    16B  6 Oct 18:48 /Users/overflow/Documents/tools/python -> /usr/bin/python3

$ /usr/bin/python3 -V
Python 3.8.9

$ echo $PATH | sed 's/:/\n/g'
/Users/overflow/Documents/tools
/Users/overflow/Documents/Dropbox/productivity/bin
/Users/overflow/Documents/tools/confluent-6.1.0/bin
/Users/overflow/.sdkman/candidates/java/current/bin
/Users/overflow/.nvm/versions/node/v16.10.0/bin
/Users/overflow/bin
/usr/local/bin
/opt/homebrew/bin
/opt/homebrew/sbin
/usr/local/bin
/usr/bin
/bin
/usr/sbin
/sbin
over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

Given the path is not being utilized, it is being overridden by a shell alias. This can be confirmed by typing set | grep python

If you are using virtualenv:

Try: /usr/bin/python3 -m venv python3.8.9

The common MacOS python managers are:

  1. pythonz

List installs using pythonz list

Change using: /usr/bin/python3 -m venv python3.8.9

  1. pythonbrew

List installs pythonbrew list

Use pythonbrew switch 3.8.9 to move to the new version.

  1. pyenv

Claims to use only $PATH. Included for completeness, but just in case

List installs pyenv versions

Use pyenv global 3.8.9 to move to the new version.


To remove any of these remove the appropriate line from your ~/.bashrc or ~/.zshrc file.

You can locate the line with grep ~/.bashrc python.

over 4 years ago · Santiago Trujillo Relatório

0

I can give you some general troubleshooting tips and a band-aid that can replace a symlink.

$(which python) -V

This should get you the version for python3.

Other thing worth checking:

which python2

This should point to some standard location, /usr/bin/python2 for example. If it isn't pointed there, might be worth understanding why.

In general, Macs have some quirks. The fact that a new MacBook M4 ships with Python2 as the default is a smell that you probably shouldn't try to overwrite the default value, and for whatever reason it doesn't seem to want you to.

Simple answer: set an alias.

echo 'alias python="python3"' >> ~/.zshrc && source;

This will work for you and should not interfere with any potential other systems.

Better answer:

As others have described, create a virtual environment and source venv/bin/activate.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda