A developer’s build fails with a version error, or a tool says Python isn’t installed when the developer is sure it is. On a Mac, both can be true at once. Apple’s own python3 sits in /usr/bin. Homebrew installs to /opt/homebrew on Apple Silicon and to /usr/local on Intel Macs. nvm and pyenv each keep a separate copy in the user’s home folder. The version a command reports is just the first one the shell finds, which may not be the one the project runs on.

These runtimes are everywhere, so this happens often. Getting a version check right on a Mac means finding every install, knowing which one wins, and fixing the path when the wrong one runs, whether that’s on one developer’s Mac or every Mac you support.

Checking runtimes by hand vs. Robin by Atera

The rest of this guide is the manual route. The table below shows what each stage takes by hand, and what Robin by Atera does for routine end-user cases.

Stage

By hand

With Robin by Atera

Check the version

Run python3 --version, node -v, and java -version in a remote session or a script

Robin checks the required runtime commands, such as Python, Node.js, or Java

Find which install runs

Run which -a and java_home -V, then work out which path wins

Robin reports the versions and command paths it finds

Spot the problem

Compare the results against what the project or app needs

The results help IT identify a missing or mismatched prerequisite before provisioning changes

Fix PATH, JAVA_HOME, or the developer tools

Edit the shell profile or developer tools setup, then check again

This stays with your technicians

» Here’s how to install Atera’s macOS agent

Quick fix: see which versions run and where they come from

These commands get you an answer in under a minute, in Terminal or as a shell script you run remotely. The sections below cover installs these commands miss and how to fix the wrong version.

  1. Run python3 --version; node -v; java -version to see the version each command runs. If python3 brings up a prompt to install the command line developer tools, that Mac has no working Python yet
  2. Run which -a python3 node java to list every copy on PATH in the order the shell searches them. The first path listed for each runtime is the one that runs
  3. Run /usr/libexec/java_home -V to list every installed JDK, including any that aren’t on PATH. When you run steps 1 to 3 as a remote script, they run as root, so they won’t show per-user installs from nvm or pyenv

Check which version runs and where it comes from

A Mac can have the same runtime installed several times, and the command you type runs only the first one it finds. The subsections below cover Python, Node.js, and Java one at a time. Each starts with the version check, then shows which install that version came from and how to find installs that aren’t on PATH.

How to check your Python version on Mac

Start with the version the python3 command returns, then find out which install it came from.

  1. Run python3 --version to see the version that runs by default
  2. Run python3 -c "import sys; print(sys.executable); print(sys.prefix)" to see the interpreter that actually ran and the installation it belongs to
  3. Run which -a python3 to list every python3 on PATH in search order. The first path listed is the one that runs

    If which -a shows /usr/bin/python3 first while sys.executable shows a path under /Library/Developer/CommandLineTools, that’s expected. /usr/bin/python3 is a stub that hands the command over to whichever developer directory is active, either the Command Line Tools or a full Xcode install. To confirm which one:

    Check Python version
  4. Run xcode-select -p to see the active developer directory
  5. Run xcrun --find python3 to get the real binary behind the stub

The sys.prefix path tells you which installer each Python came from:

sys.prefix or path contains

Source

/Library/Developer/CommandLineTools or Xcode.app

Apple, through the developer tools

/opt/homebrew (Apple Silicon) or /usr/local/Cellar (Intel)

Homebrew

/Library/Frameworks/Python.framework

The python.org installer

~/.pyenv/versions

pyenv

To find Python installs that aren’t on PATH, check the locations each installer uses. A zsh: no matches found result means nothing is installed in that location.

  1. Run ls -d /Applications/Python* to find python.org installs’ app folders
  2. Run ls -d /Library/Frameworks/Python.framework/Versions/* to list python.org framework versions
  3. Run pkgutil --pkgs | grep -i python to find installer package receipts
  4. Run brew list --versions | grep -i python to list Homebrew’s Python formulae

    Find additional Python versions
  5. Run pyenv versions to list pyenv’s versions. The asterisk marks the active one, and the “set by” note shows whether a project’s .python-version file or the global setting chose it. Run it from inside the project folder to see the version that project uses

    pyenv command on Mac

You can do this at scale as well. RMM and MDM scripts usually run as root, and root can’t see installs in a user’s home folder, such as pyenv. Here’s a script that checks the system-wide locations first, then loops through every user account and lists the pyenv versions in that user’s home folder:

The Script:

Atera does not guarantee the integrity, availability, security, virus-free, safety, lawfulness, non-infringement, rights’ status, or functionality of the scripts. The use of the shared scripts is at your own risk. Scripts are provided “AS IS”. *

#!/bin/bash
ls -1 /Library/Frameworks/Python.framework/Versions /opt/homebrew/Cellar/python@* /usr/local/Cellar/python@* 2>/dev/null
for user in $(dscl . -list /Users UniqueID | awk '$2 >= 501 {print $1}'); do
  home=$(dscl . -read /Users/"$user" NFSHomeDirectory | awk '{print $2}')
  ls -1 "$home/.pyenv/versions" 2>/dev/null | sed "s|^|$user pyenv: |"
done
Script copied to clipboard

The $2 >= 501 filter limits the loop to regular user accounts. It lists version folders instead of running each Python, because running a binary that a user controls with root privileges is a risk you don’t need to take for an inventory.

Before relying on /usr/bin/python3 in a script, check xcode-select -p. If it returns an error, the stub has no Python behind it, and calling it triggers the developer tools install prompt instead of returning a version. In Atera’s RMM platform, you can run this script across selected Macs and read the output for each device. And if you don’t have a script to run, AI Copilot can generate or adapt it from a plain-language description.

With Robin by Atera: When an employee reports that Python is missing or the wrong version, Robin checks the required runtime commands and reports the versions and command paths it finds, so your technician doesn’t need a remote session to run these commands and read the output.

» Here’s how to enable remote management on Mac

How to check your Node.js version on Mac

The Node.js check works the same way: get the version, then confirm the binary behind it.

  1. Run node -v to see the active Node.js version
  2. Run npm -v to see the npm version that came with it
  3. Run which -a node npm to list every node and npm on PATH in search order

    Check node.js version
  4. Run node -p "process.execPath + ' ' + process.version" to print the exact executable that runs, with its version. Run it from the project folder to confirm which install that project uses

    Check node js executable path
  5. A path under ~/.nvm/versions/node means nvm manages that install. A path under /opt/homebrew/bin or /usr/local/bin usually means a Homebrew install, which brew list --versions node confirms. When nvm is in use, two more checks matter:
  6. Run nvm ls --no-alias to list installed versions. The -> arrow marks the one active in this shell
  7. Run nvm use <version> to switch versions, then run which -a node again to confirm the change

    nvm use version

nvm switches the version only for the current shell session. A new Terminal window goes back to nvm’s default version, or to the version in a project’s .nvmrc file when someone runs nvm use in that folder. So the version you see in your remote support session may not be the one the developer’s own terminal runs.

At scale: nvm names each folder after the version it holds, so this script lists Homebrew’s Node.js versions and each user’s nvm versions without running Node.

The Script:

Atera does not guarantee the integrity, availability, security, virus-free, safety, lawfulness, non-infringement, rights’ status, or functionality of the scripts. The use of the shared scripts is at your own risk. Scripts are provided “AS IS”. *

#!/bin/bash
ls -1 /opt/homebrew/Cellar/node /usr/local/Cellar/node 2>/dev/null
for user in $(dscl . -list /Users UniqueID | awk '$2 >= 501 {print $1}'); do
  home=$(dscl . -read /Users/"$user" NFSHomeDirectory | awk '{print $2}')
  ls -1 "$home/.nvm/versions/node" 2>/dev/null | sed "s|^|$user nvm: |"
done
Script copied to clipboard

With Robin: The hard part of a Node.js ticket is usually the path, not the version number. Robin reports the command paths it finds along with the versions, so you can see which install answers to node without working through which -a and nvm yourself.

How to check your Java version on Mac

Java adds two questions the other runtimes don’t have: whether the install is a full JDK or a runtime only, and which vendor built it.

  1. Run java -version to see the version and build. A first line that starts with openjdk means an OpenJDK build. Java(TM) SE Runtime Environment on the second line means an Oracle build
  2. Run javac -version to check for the compiler. If java works but javac doesn’t, the Mac either has a runtime only or has a JDK that isn’t on PATH
  3. Run /usr/libexec/java_home -V (capital V) to list every JDK and runtime the system knows about, with its vendor and path. That includes JDKs in /Library/Java/JavaVirtualMachines and the legacy Java 8 Internet Plug-In
  4. Run /usr/libexec/java_home -v <version> (lowercase v) to get the path of a specific version, for example java_home -v 21
  5. Run echo $JAVA_HOME to see whether JAVA_HOME is set in this shell

    Check Java version

On a Mac, /usr/bin/java is also a stub. It runs the JDK that JAVA_HOME points to. If JAVA_HOME isn’t set, it runs the newest JDK java_home finds. So when java -version doesn’t match the version a developer expects, check JAVA_HOME before anything else.

Set java stub

At scale: Every JDK ships with a release file that states its version. This script lists system-wide JDKs with their vendors, then reads the release file of each JDK in every user’s home folder. Keep the vendor column from java_home -V, since it shows which vendor built each JDK.

The Script:

Atera does not guarantee the integrity, availability, security, virus-free, safety, lawfulness, non-infringement, rights’ status, or functionality of the scripts. The use of the shared scripts is at your own risk. Scripts are provided “AS IS”. *

#!/bin/bash
/usr/libexec/java_home -V
for user in $(dscl . -list /Users UniqueID | awk '$2 >= 501 {print $1}'); do
  home=$(dscl . -read /Users/"$user" NFSHomeDirectory | awk '{print $2}')
  grep -H JAVA_VERSION "$home"/Library/Java/JavaVirtualMachines/*/Contents/Home/release 2>/dev/null
done
Script copied to clipboard

How to fix “command not found” and the wrong version

Most runtime tickets on a Mac come down to one of two things: the shell can’t find the command at all, or it finds a different install than the developer expects. Here are the main problems and how to fix them:

“zsh: command not found” or a developer tools prompt

zsh: command not found means nothing with that name is in any folder on PATH. The cause differs by runtime:

What you see

Likely cause

zsh: command not found: python

Recent macOS versions don’t include a python command, only python3

zsh: command not found: node with nvm installed

The nvm lines aren’t in ~/.zshrc, so nvm never loads in that shell

command not found for a Homebrew install on Apple Silicon

/opt/homebrew/bin was never added to PATH

A dialog saying the command requires the command line developer tools

The command ran Apple’s /usr/bin stub, and no developer tools are installed

xcrun: error: invalid active developer path

A macOS upgrade removed or broke the developer tools the stub points to

To fix a command that isn’t on PATH:

  1. Run echo $PATH to list the folders on PATH. The shell searches them from left to right, so a version manager’s folder near the start, such as ~/.pyenv/shims or ~/.nvm/versions/node/<version>/bin, wins over anything after it.

    List folders on PATH
  2. Run brew --prefix to confirm where Homebrew lives on this Mac. It returns /opt/homebrew on Apple Silicon and /usr/local on Intel. On a Mac that was migrated from an Intel machine, an old Homebrew in /usr/local can still be sitting ahead of the native one
  3. Open ~/.zshrc and add a line at the end that puts the preferred runtime’s folder first, for example export PATH="/opt/homebrew/bin:$PATH"
  4. Run source ~/.zshrc && rehash to reload the file and clear zsh’s cached command locations To install or repair the Command Line Tools on a Mac you’re sitting at: run xcode-select –install and follow the dialog. If you see the xcrun: error: invalid active developer path error after a macOS upgrade, the same command normally fixes it.
  5. If you’re doing this remotely, xcode-select --install waits for the user to click through a dialog, so it won’t finish in an unattended script. Instead, run touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
  6. Run softwareupdate -l to find the Command Line Tools label
  7. Run softwareupdate -i "<label>" to install it
  8. Delete the file in /tmp

The wrong Python or Node.js version runs

macOS builds PATH from several startup files in sequence, with ~/.zprofile read before ~/.zshrc in a normal Terminal window. Whichever file adds a folder to the front of PATH last decides which install runs.

  1. Run echo $PATH | tr ':' '\n' to list the folders on PATH in search order. A Mac migrated from an Intel machine can still have an old Homebrew in /usr/local sitting ahead of the native one in /opt/homebrew

Then use the PATH steps in the previous section to put the preferred runtime’s folder first, and reload the file.

Version managers change PATH every time a shell starts, so they need their own setting:

  • pyenv: Run pyenv global <version> to set the default, or pyenv local <version> in a project folder to pin that project only.
  • nvm: nvm use only lasts for the current shell. Run nvm alias default <version> to set the version for every new shell, or add a .nvmrc file to the project folder.

Remote scripts and apps launched from the Dock, including IDEs, don’t read ~/.zshrc. A PATH fix that works in Terminal may not change what they run, so test in the tool that’s failing, not only in Terminal.

Java ignores the version you selected

A JAVA_HOME set in one Terminal window is lost when that window closes, and build tools such as Maven and Gradle read JAVA_HOME too. If JAVA_HOME isn’t saved, or is saved for the wrong version, both java and the build tools run the wrong JDK. Confirm the version you need is installed with /usr/libexec/java_home -v <version> before saving it. If that version is missing, java_home prints a warning and falls back to its default JDK.

  1. Run echo 'export JAVA_HOME=$(/usr/libexec/java_home -v 21)' >> ~/.zshrc, replacing 21 with the version the developer needs
  2. Run source ~/.zshrc to load the setting in the current shell

IDEs such as IntelliJ IDEA keep their own JDK setting and don’t read ~/.zshrc. If the build works in Terminal but fails in the IDE, check the project’s JDK setting inside the IDE.

Where Robin stops and your technicians start:Editing PATH and shell profiles, installing or repointing the developer tools, and setting JAVA_HOME all change how a developer’s environment works, so those changes stay with your technicians. Robin’s runtime use case covers checking the required runtime commands and reporting the versions and command paths it finds. Taking those routine checks off the queue gives your team time for the fixes above.

Take routine runtime checks off the ticket queue

A version number tells you very little until you know which install it came from. Most “wrong version” tickets on a Mac come down to which runtime the shell finds first: Apple’s own python3, a Homebrew build, or a per-user nvm or pyenv copy. Once you can see every install and which one wins, the fix is usually a single change to PATH or JAVA_HOME.

Atera’s Robin takes the checking off your technicians’ plate for routine cases. On Macs with an assigned, reporting Atera Agent, Robin checks the required runtime commands, such as Python, Node.js, or Java, and reports the versions and command paths it finds. Those results help IT spot a missing or mismatched prerequisite before provisioning changes. Your technicians still make the fixes, and Atera’s remote scripting lets them run the checks and fixes from this guide across selected Macs. Robin is sold separately as an add-on to the Atera IT suite.

» See Robin in action or try Atera for free

Frequently Asked Questions

Was this helpful?

* Scripts are provided for your benefit. You understand and acknowledge that when downloading and/or copying and/or using the Scripts: (i) you may be exposed to Scripts from a variety of sources, (ii) Atera is not responsible and takes no liability for the accuracy, usefulness, integrity, lawfulness, title or infringement, security, functionality or Intellectual Property Rights of, or relating to, such Scripts; and (iii) the Scripts are provided “AS IS” and “AS AVAILABLE”, and may have errors, and may not be malware-free, and that your interactions with, and use of, the Scripts is at your sole risk and free will. You hereby agree to waive, and hereby do waive, any legal or equitable rights or remedies you may have against Atera with respect to the Scripts.

Related Articles

How to fix a USB device not recognized in Windows 11

Read now

How to fix the Windows search bar not working in Windows 10 and 11

Read now

How to fix Google Drive not syncing

Read now

How to fix Bluetooth not working in Windows 11

Read now

Endless IT possibilities

Boost your productivity with Atera’s intuitive, centralized all-in-one platform