Answer the question
In order to leave comments, you need to log in
How to import a module from a variable?
I wrote a code that checks for the presence of a module:
try:
import this
except ModuleNotFoundError:
system('pip install this') The
question is, how can I programmatically substitute other modules instead of 'this'?
Answer the question
In order to leave comments, you need to log in
You don’t need to want this
. Better the application will swear that there are no packages, and the user will manually create the environment and install the dependencies.
You only need to create requirements.txt / Pipfile and indicate in the manual that manual installation of dependencies is required
Or create a package and write the same for "auto " install dependencies from the same files in setup.py
You can use importlib . But don't, the idea of automatically installing modules is a bad idea.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question