Reputation: 1
I am new to scene and I have made a simple python script that should play a video
import os
import sys
import pygame
from pygame.locals import *
from subprocess import Popen
movies = "revolving.mp4"
playingmovie = ["omxplayer","-b","/home/pi/Videos/"+movies]
omxc = Popen(playingmovie, stdout=subprocess.PIPE, preexec_fn=os.setsid)
Which gives off the following error:
File "test2.py", line 9, in <module>
omxc = Popen(playingmovie, stdout=subprocess.PIPE, preexec_fn=os.setsid)
NameError: name 'subprocess' is not defined
I have tried to do some research on the subject but found no answer to my problem. In said research, I found that I should run the command
sudo find / | grep subprocess
Which returns
/usr/lib/python2.7/subprocess.pyc
/usr/lib/python2.7/subprocess.py
/usr/lib/python3.5/__pycache__/subprocess.cpython-35.pyc
/usr/lib/python3.5/subprocess.py
/usr/lib/python3.5/asyncio/__pycache__/base_subprocess.cpython-35.pyc
/usr/lib/python3.5/asyncio/__pycache__/subprocess.cpython-35.pyc
/usr/lib/python3.5/asyncio/base_subprocess.py
/usr/lib/python3.5/asyncio/subprocess.py
/usr/lib/pypy/lib-python/2.7/__pycache__/subprocess.pypy-41.pyc
/usr/lib/pypy/lib-python/2.7/subprocess.py
/usr/lib/pypy/lib_pypy/__pycache__/_subprocess.pypy-41.pyc
/usr/lib/pypy/lib_pypy/_subprocess.py
How can I solve this?
Upvotes: 0
Views: 2636
Reputation: 8017
You are trying to use subprocess
but you only imported one class from subprocess package.
You could import whole subprocess
and use it like:
import os
import sys
import pygame
from pygame.locals import *
import subprocess
movies = "revolving.mp4"
playingmovie = ["omxplayer","-b","/home/pi/Videos/"+movies]
omxc = subprocess.Popen(playingmovie, stdout=subprocess.PIPE, preexec_fn=os.setsid)
Upvotes: 2