0

I'm newbie to python. Recently I practiced module subprocess, but I got an ImportError when I use from subprocess import Popen , the error message said: ImportError: cannot import name Popen.

My python version info is Python 2.6.6 (r266:84292, Aug 18 2016, 15:13:37) [GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2, and my OS is centOS.

I searched for help using both Google and stackoverflow, but didn't find the answer. Can you give me some instruction? Thanks very much~

//============================

update:

As @BorrajaX commended below, I named a file in working directory as subprocess.py, which shadowed the 'offical' subprocess module.

This question is solved, Thank you all~

leo_z
  • 11
  • 3
  • 1
    Can you show us the exact code you're running? I've tried the same thing on Python 2.6.6 (same revision, date, etc as you) on CentOS 6 and it works just fine. – larsks Oct 25 '16 at 03:11
  • Do you have a file `subprocess.py` in the same directory (_module_, to be nitpicking) as the script where you get the error (or _close_ to it)? It could be that the "official" `subprocess` module is being shadowed by another module with the same name. – Savir Oct 25 '16 at 03:14
  • 1
    Please provide the full exact stacktrace you are receiving so we can also see the name of your python file. Even if you created another file in your project that matches subprocess that would cause this problem. Please confirm. – idjaw Oct 25 '16 at 03:16
  • 1
    Thanks all, just as @BorrajaX said, I named a file as `subprocess.py` by mistake. After I rename the file it works fine. That's a stupid fault X_X – leo_z Oct 25 '16 at 03:21

0 Answers0