4 ms·
for simple scripts, this is the easiest and works. python3 -m venv venv source venv/bin/activate pip install whatever echo "source path/to/venv/bin/act
by FergusArgyll 3y ago
for simple scripts, this is the easiest and works.
python3 -m venv venv
source venv/bin/activate
pip install whatever
echo "source path/to/venv/bin/activate && python3 path/to/app.py" > myscript
mv myscript /usr/local/bin
and just use myscript.
I use this for a lot of little scripts
- bomewish 3y agoWhy not just Path/to/venv/bin/python path/to/app.py? Neat trick though, gonna adopt it!
- ctippett 3y agoI haven't tried this myself, but you could probably save yourself the wrapper script and execute your script directly by adding a shebang pointing to the Python executable from your virtual environment. printf '%s\n%s\n' "#!path/to/venv/bin/python3" "$(cat path/to/app.py)" > /usr/local/bin/myscript