Home > Enterprise >  Run process with keyword arguments using python
Run process with keyword arguments using python

Time:01-05

More Generally: How can I run a process that runs from the terminal with required keyword arguments using python?

It seems subprocess.Popen is what I want to use.

Here is what I try to run from inside a script:

from subprocess import Popen
Popen(['goodreads-user-scraper', '--user_id 149832357'])

“goodreads-user-scraper” is recognized, but I don’t understand how to pass a keyword argument. I know how to pass an argument, but if I remove “—user_id” I still get same problem. enter image description here

I have installed goodreads-user-scraper. It works well from the terminal. It is a python package that you can run from the terminal. Repository found enter image description here

Research

In my research I have found these two that seem helpful, but I haven’t been able to adapt the answers to my needs:

CodePudding user response:

Separate all of your arguments like this:

from subprocess import Popen
Popen(['goodreads-user-scraper', '--user_id', '149832357'])
  • Related