简体   繁体   中英

How do i use Subprocess.popen() with pyinstaller?

I have a bunch of code and one of the lines is this (in abc.py):

meow = subprocess.Popen("python ./Functions/cat.py")

Now when i use pyinstaller.exe --onefile .\\abc.py

It makes me a single exe and it implements all the function but the function containing above line does not work.

How do i include cat.py in exe and use it with subprocess.popen?

My folder view is

  -Project x -abc.py -Functions -cat.py -me.py -ow.py 

Cat.py has a function which listens for input and runs forever till i have to stop it based on certain input.

I am running abc.py and based on certain input i have to run cat.py along with abc.py and on some another input i have to stop cat.py(using .kill()) and abc.py will still be running.

How do i implement this in a single exe using pyinstaller?

There are a couple of ways to handle this issue. I believe if you called cat.py with an import statement, it would package just fine. The other option is to create a .spec file, and then package cat.py as a data file ( or the entire function folder using the Tree class ). If you package it as a data file, check out this post for coding to call it while developing as well as once its packaged by --onefile.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM