Python3 shebang in conda windows

From raju

shebang in Python3 scripts under windows when using conda

Situation:

A lot of python3 scripts expect an executable called python3. For example, they may have a shebang like

    #! /usr/bin/env python3
    

But if you are using Anaconda in Windows then there is no python3 executable. The executable is simply called python. Because of this, the scripts will fail with

    /usr/bin/env: ‘python3’: No such file or directory
    

Solution: Use a pass through script such as https://github.com/KamarajuKusumanchi/rutils/blob/master/bin/windows/python3 which calls python from the py38 environment.

Assumptions:

  • Using Windows 7, Anaconda
  • The environment name, py38, is user specific. Change it accordingly.

tags | make shebangs in python3 scripts portable on windows