Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use Python 2.7 subprocess module from Python 2.6?

Tags:

python

pip

Can I use Python 2.7 modules from Python 2.6? Or do something to achieve the same effect?

I'm limited to use Python 2.6, but an issue exists in the subprocess module provided by Python 2.6. This is fixed in Python 2.7. I'm curious if I rig this up using pip (or equivalent) to sidestep the bug temporarily until upgrading one day. How would I go about doing this?

like image 620
sholsapp Avatar asked Feb 12 '12 18:02

sholsapp


People also ask

Is subprocess already installed in Python?

The subprocess module is part of the standard library, it doesn't need (can't, actually) be installed.

Is subprocess part of Python standard library?

The subprocess library allows us to execute and manage subprocesses directly from Python. That involves working with the standard input stdin , standard output stdout , and return codes. We don't have to install it with PIP, since it's part of the Python standard library.

What is Python subprocess module?

Subprocess in Python is a module used to run new codes and applications by creating new processes. It lets you start new applications right from the Python program you are currently writing. So, if you want to run external programs from a git repository or codes from C or C++ programs, you can use subprocess in Python.

How do I use OS Popen in Python?

Python method popen() opens a pipe to or from command. The return value is an open file object connected to the pipe, which can be read or written depending on whether mode is 'r' (default) or 'w'. The bufsize argument has the same meaning as in open() function.


1 Answers

Yes, usually. The difference between 2.6 and 2.7 isn't very big, as 2.7 is supposed to be a bridge between 2.6 and 3.0. As a result, most Python modules for 2.7 will work in both of these versions (usually better in 2.6 than 3.0).

Of course, the only surefire way to know the answer is to try!

EDIT: To be clear, I do not recommend that you do this at all, if you have a choice. Hacking around a Python installation just because of a Python bug in one module is a bad idea.

like image 88
Etienne Perot Avatar answered Oct 02 '22 14:10

Etienne Perot