Skip to content

Bug: Python is now typically invoked with python3, not with python #17

@tcrgit

Description

@tcrgit

The zshell script ran but with errors for images (and markdown etc) complaining it could not find the python command.

./exportnotes.zsh:296: command not found: python

This was because in recent versions of Python installers on macos, python is invoked viapython3, not python.

I've long had an alias python='python3' in my .profile for my bash interactive shell, but of course the alias didn't get inherited by zshell even though it inherited the $PATH environment variable with the correct path/to/python.

Everything worked after I added the alias into a .zshenv file. (Btw, this is better recommendation than editing the .zshrc because the latter files are specific to interactive shells, not zshell scripts invoked from bash or another shell. Placing any aliases in the .zshenv applies to all zshell invocations. Obviously soft-linking python to python3 with ln -s is a good option too; this is all a hangover from when we used to have python 2 and 3 on the same machines...)

Anyway I'd suggest a small revision to the read.me documentation to reflect this and make the installation more interactive shell agnostic. E.g., in the Install Python and Dependencies section:

Note: Python must be on your zshell path, and it is invoked from the exportnotes.zsh script with python and not python3. You may need to alias python='python3' in the ~/.zshenv file, and/or you may need to add the path/to/python to your $PATH variable in the ~/.zshenv file.

I suppose another solution would be to change the zshell script to invoke python via python3 in the now usual fashion. Alternately, you could even check whether the command python exists and alias python as python3 if it does not, e.g:

# Check if 'python' command exists
if ! command -v python &> /dev/null; then
    # If 'python' command does not exist, alias it to 'python3'
    alias python='python3'
fi

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions