0

I was taking a course on django and when creating a virtual environment, they used the following command:

mkvirtualenv envname --python=/usr/bin/python3.8

I've no idea what the additional arguments mean, and just wanted an explanation. Many thanks! Apologies if this is something simple - just starting out.

Dai
  • 141,631
  • 28
  • 261
  • 374
Selerium
  • 3
  • 1
  • The shell (Bash or otherwise) simply executes the command line, using the first token as the command and the others as string arguments. So your question is actually, what does this option mean to the command `virtualenv`? – tripleee Aug 29 '21 at 13:01
  • In general, you can find the documentation for each command and its options in its manual page. Many commands also support a `--help` option which typically displays a list of the supported options with a brief description of each. – tripleee Aug 29 '21 at 13:03
  • 1
    Your question is not related to `bash` at all; `--python` is a parameter to `mkvirtualenv`. – Manfred Aug 29 '21 at 13:03
  • @tripleee The `--python` parameter is not documented, as far as I can tell. – Dai Aug 29 '21 at 13:03
  • thanks @tripleee , I shall look into that. – Selerium Aug 29 '21 at 13:06
  • @Dai - precisely, can't find any documentation for it, which is why I was hoping to find someone who knew it. Oh well :) – Selerium Aug 29 '21 at 13:07
  • @Selerium See my answer. – Dai Aug 29 '21 at 13:10
  • @Dai just did - explained beautifully. Thank you so much!!! – Selerium Aug 29 '21 at 13:11

1 Answers1

0
function mkvirtualenv {
    [...]
    while [ $i $tst $# ]
    do
    a="${in_args[$i]}"
    case "$a" in
        [...]
        -p|--python)
            i=$(( $i + 1 ));
            interpreter="${in_args[$i]}";
            interpreter="$(virtualenvwrapper_absolutepath "$interpreter")";;
        [...]
    esac
    i=$(( $i + 1 ))
done
  • The above code handles the --python command-line argument.
  • The --python (double-dash) and -p (single-dash) arguments are treated as synonyms.
  • It's used to set the path to the actual Python interpreter/engine that your new virtual-environment will use.
  • This is needed because you can have multiple, different, and incompatible Python installs side-by-side on the same physical computer, but you need to select a single unambiguous (and correctly versioned) Python executable to run your Python programs.
Dai
  • 141,631
  • 28
  • 261
  • 374