Re:Shell Scripting with Elixir
by datadeft on Tuesday February 13, 2024 @04:07AM
(#39355897)
One detail I really like about this is that you can install packages during the script run.
[ Parent
| on HN ]
Ruby can do this too:
require 'bundler/inline'
gemfile do
source 'https://rubygems.org'
gem 'json', require: false
gem 'nap', require: 'rest'
gem 'cocoapods', '~> 0.34.1'
endCan't Python do the same? Like !pip install blahblah
That's not Python syntax. It's a Jupyter extension.
Right, but Python can run command line code in subprocesses too, so it should be possible to run a pip install jupyter command inside Python.
The problem is that installing dependencies for the user or globally will lead to version conflicts.
You need a separate virtual environment or a custom installation directory for each script to avoid conflicts.
There are script runners and copy-pastable code snippets for Python that handle this by creating the virtual environment and installing the dependencies in it.
Check out https://github.com/stars/dbohdan/lists/python-scripts-with-d... (disclosure: my list, and it includes my repository).