importlib: import X as Y; from A import B

Chris Angelico rosuav at gmail.com
Sun Aug 9 00:26:10 EDT 2020


On Sun, Aug 9, 2020 at 1:25 PM Jason Friedman <jsf80238 at gmail.com> wrote:
>
> I have some code I'm going to share with my team, many of whom are not yet
> familiar with Python. They may not have 3rd-party libraries such as pandas
> or selenium installed. Yes I can instruct them how to install, but the path
> of least resistance is to have my code to check for missing dependencies
> and attempt to install for them. This code works as desired:
>

I'd personally much prefer to ship a 'requirements.txt' alongside your
code, and use that to govern all the installations. If you want, you
could still do a startup check to figure out if everything's
installed, but I'd recommend replacing all the pip commands with a
single "pip install -r requirements.txt" to fetch everything.

ChrisA


More information about the Python-list mailing list