[Tutor] pip install of subprocess module

Alan Gauld alan.gauld at yahoo.co.uk
Mon Sep 18 18:24:31 EDT 2017


On 18/09/17 18:59, Derek Smith wrote:

> I want to use the subprocess.run module b/c per the> docs os.system is antiquated

Its not so much antiquated but it is deprecated because
it is severely limited, all you get back is an error code.

> Why am I doing wrong below?  

You are trying to install it, but subprocess is part
of the standard library, it should already be installoed.

Just use the >>> prompt and try

>>> import subprocess

If you don't get an error then its already there.

> python this is a new module called os.system 

subprocess is its own moduile it is not part of os.

import os
import subprocess

> since this py file requires os.system and os.spawn*

Both of those can be replaced by calls within
subprocess but  they will not be called by
those names. Read the subprocess module documents
carefully they give example code for replacing
these functions.


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list