Proper shebang for python3
Manfred Lotz
ml_news at posteo.de
Sat Jul 20 15:40:03 EDT 2019
On Sat, 20 Jul 2019 14:11:21 -0400
Michael Speer <knomenet at gmail.com> wrote:
> You may want to use `#!/usr/bin/env python3` instead.
>
In my case it doesn't matter. However, I agree that your suggestion is
usually preferable.
> There is a concept in python called the virtual environment. This
> used to be done with a tool called virtualenv in python2, and is now
> done mainly through a venv module in python3.
>
> A virtual environment goes into a directory of your choosing and will
> have its own python3 executable, and pip3 executable, and when you add
> dependencies, they are also placed into the directory structure under
> your chosen directory.
>
> When you do a `. <directory>/bin/activate` the included source will
> places the virtual environment's bin/ folder at the beginning of your
> PATH environment variable, making it the default python3 when you
> type it without a full path.
>
> This allows you to run scripts that need different, or even
> conflicting, sets of dependencies without bothering with the
> underlying linux distribution's python installation's modules.
>
New to me. Interesting.
> If you use `#!/usr/bin/python3`, it will always use exactly the system
> version that is installed, and the system's installed modules.
>
> Your scripts will still default to the system installation if a
> virtual environment is not activated. So you lose nothing by doing it
> this way, but gain a little control from it.
>
Ok, understood.
--
Manfred
More information about the Python-list
mailing list