Using ~ in a shebang line

102 views Asked by At

I'm trying to make a runnable Python script with a custom virtual environment. Instead of activating the virtual environment or specifying the full path I tried to use ~ in the shebang line.

  • Does not work out (expected):
    #!~/path/to/bin/python and running the script as ./script.py.

  • Does not work out (lacks pip dependencies):

    #!/full/path/to/bin/python and running the script as ./script.py.

  • Works out:
    No shebang line and running the script as ~/path/to/venv/bin/python script.py.

0

There are 0 answers