5 ms·
One detail I really like about this is that you can install packages during the script run. Mix.install([ {:req, "~> 0.2"}, {:floki, "~> 0.30.0"}
by datadeft 3y ago
One detail I really like about this is that you can install packages during the script run.
Mix.install([
{:req, "~> 0.2"},
{:floki, "~> 0.30.0"}
])
- lambdaba 3y agoRuby 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' end
- behnamoh 3y agoCan't Python do the same? Like !pip install blahblah
- gkbrk 3y agoThat's not Python syntax. It's a Jupyter extension.
- behnamoh 3y agoRight, but Python can run command line code in subprocesses too, so it should be possible to run a pip install jupyter command inside Python.
- networked 3y agoThe problem is that installing dependencies for the user or globally will lead to version conflict. 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. They automatically create the virtual environment and install the dependencies when the script runs. I have bookmarked several in https://github.com/stars/dbohdan/lists/python-scripts-with-deps https://github.com/stars/dbohdan/lists/python-scripts-with-d... (disclosure: not only is this my list, it also includes my project).
- behnamoh 3y agoThanks, I checked out the link, it's quite handy!