Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use imported subprocess module #372

Closed
s1113950 opened this issue May 18, 2019 · 7 comments
Closed

Unable to use imported subprocess module #372

s1113950 opened this issue May 18, 2019 · 7 comments

Comments

@s1113950
Copy link

I've even tried using subprocess32 as a replacement module, but no matter what I do the subprocess module shows up as empty somehow:

[INFO   ] [Kivy        ] v1.10.1
[INFO   ] [Python      ] v3.7.1 (default, Feb  4 2019, 20:11:34) 
[Clang 10.0.0 (clang-1000.11.45.5)]
{'__name__': 'subprocess', '__doc__': None, '__package__': None, '__loader__': None, '__spec__': None}
 Traceback (most recent call last):
   File "/Users/robertso/kivy-ios/piles-ios/YourApp/main.py", line 7, in <module>
 AttributeError: module 'subprocess' has no attribute '__file__'

it exists but doesn't contain anything inside of it.

Here are the files related to subprocess in my kivy-ios app; I've checked them out and the subprocess module appears to exist:

(venv) robertso@robertso-mac02:~/kivy-ios$ find . -name "*subprocess*"
./dist/hostpython3/lib/python3.7/lib-dynload/_posixsubprocess.cpython-37m-darwin.so
./dist/hostpython3/lib/python3.7/test/__pycache__/test_subprocess.cpython-37.opt-2.pyc
./dist/hostpython3/lib/python3.7/test/__pycache__/test_subprocess.cpython-37.opt-1.pyc
./dist/hostpython3/lib/python3.7/test/__pycache__/test_subprocess.cpython-37.pyc
./dist/hostpython3/lib/python3.7/test/test_subprocess.py
./dist/hostpython3/lib/python3.7/test/test_asyncio/__pycache__/test_subprocess.cpython-37.opt-2.pyc
./dist/hostpython3/lib/python3.7/test/test_asyncio/__pycache__/test_subprocess.cpython-37.opt-1.pyc
./dist/hostpython3/lib/python3.7/test/test_asyncio/__pycache__/test_subprocess.cpython-37.pyc
./dist/hostpython3/lib/python3.7/test/test_asyncio/test_subprocess.py
./dist/hostpython3/lib/python3.7/test/subprocessdata
./dist/hostpython3/lib/python3.7/subprocess.pyc
./dist/hostpython3/lib/python3.7/subprocess.py
./dist/hostpython3/lib/python3.7/__pycache__/subprocess.cpython-37.pyc
./dist/hostpython3/lib/python3.7/__pycache__/subprocess.cpython-37.opt-2.pyc
./dist/hostpython3/lib/python3.7/__pycache__/subprocess.cpython-37.opt-1.pyc
./dist/hostpython3/lib/python3.7/asyncio/subprocess.py
./dist/hostpython3/lib/python3.7/asyncio/__pycache__/base_subprocess.cpython-37.opt-1.pyc
./dist/hostpython3/lib/python3.7/asyncio/__pycache__/base_subprocess.cpython-37.opt-2.pyc
./dist/hostpython3/lib/python3.7/asyncio/__pycache__/subprocess.cpython-37.pyc
./dist/hostpython3/lib/python3.7/asyncio/__pycache__/base_subprocess.cpython-37.pyc
./dist/hostpython3/lib/python3.7/asyncio/__pycache__/subprocess.cpython-37.opt-2.pyc
./dist/hostpython3/lib/python3.7/asyncio/__pycache__/subprocess.cpython-37.opt-1.pyc
./dist/hostpython3/lib/python3.7/asyncio/base_subprocess.py
./dist/root/python3/lib/python3.7/site-packages/subprocess32-3.5.3.dist-info
./dist/root/python3/lib/python3.7/site-packages/future/moves/subprocess.py
./dist/root/python3/lib/python3.7/site-packages/future/moves/__pycache__/subprocess.cpython-37.opt-2.pyc
./venv/lib/python3.7/site-packages/future/moves/subprocess.py
./venv/lib/python3.7/site-packages/future/moves/__pycache__/subprocess.cpython-37.pyc
./build/hostpython3/x86_64/Python-3.7.1/Lib/test/test_subprocess.py
./build/hostpython3/x86_64/Python-3.7.1/Lib/test/test_asyncio/test_subprocess.py
./build/hostpython3/x86_64/Python-3.7.1/Lib/test/subprocessdata
./build/hostpython3/x86_64/Python-3.7.1/Lib/subprocess.py
./build/hostpython3/x86_64/Python-3.7.1/Lib/__pycache__/subprocess.cpython-37.pyc
./build/hostpython3/x86_64/Python-3.7.1/Lib/asyncio/subprocess.py
./build/hostpython3/x86_64/Python-3.7.1/Lib/asyncio/__pycache__/subprocess.cpython-37.pyc
./build/hostpython3/x86_64/Python-3.7.1/Lib/asyncio/__pycache__/base_subprocess.cpython-37.pyc
./build/hostpython3/x86_64/Python-3.7.1/Lib/asyncio/base_subprocess.py
./build/hostpython3/x86_64/Python-3.7.1/Doc/library/subprocess.rst
./build/hostpython3/x86_64/Python-3.7.1/Doc/library/asyncio-subprocess.rst
./build/hostpython3/x86_64/Python-3.7.1/build/temp.macosx-10.14-x86_64-3.7/Users/robertso/kivy-ios/build/hostpython3/x86_64/Python-3.7.1/Modules/_posixsubprocess.o
./build/hostpython3/x86_64/Python-3.7.1/build/lib.macosx-10.14-x86_64-3.7/_posixsubprocess.cpython-37m-darwin.so
./build/hostpython3/x86_64/Python-3.7.1/Modules/_posixsubprocess.c
./build/python3/arm64/Python-3.7.1/Lib/test/test_subprocess.py
./build/python3/arm64/Python-3.7.1/Lib/test/test_asyncio/test_subprocess.py
./build/python3/arm64/Python-3.7.1/Lib/test/subprocessdata
./build/python3/arm64/Python-3.7.1/Lib/subprocess.py
./build/python3/arm64/Python-3.7.1/Lib/asyncio/subprocess.py
./build/python3/arm64/Python-3.7.1/Lib/asyncio/base_subprocess.py
./build/python3/arm64/Python-3.7.1/Doc/library/subprocess.rst
./build/python3/arm64/Python-3.7.1/Doc/library/asyncio-subprocess.rst
./build/python3/arm64/Python-3.7.1/build/temp.ios-aarch64-3.7/Users/robertso/kivy-ios/build/python3/arm64/Python-3.7.1/Modules/_posixsubprocess.o
./build/python3/arm64/Python-3.7.1/Modules/_posixsubprocess.c
./build/python3/x86_64/Python-3.7.1/Lib/test/test_subprocess.py
./build/python3/x86_64/Python-3.7.1/Lib/test/test_asyncio/test_subprocess.py
./build/python3/x86_64/Python-3.7.1/Lib/test/subprocessdata
./build/python3/x86_64/Python-3.7.1/Lib/subprocess.py
./build/python3/x86_64/Python-3.7.1/Lib/asyncio/subprocess.py
./build/python3/x86_64/Python-3.7.1/Lib/asyncio/base_subprocess.py
./build/python3/x86_64/Python-3.7.1/Doc/library/subprocess.rst
./build/python3/x86_64/Python-3.7.1/Doc/library/asyncio-subprocess.rst
./build/python3/x86_64/Python-3.7.1/build/temp.ios-x86_64-3.7/Users/robertso/kivy-ios/build/python3/x86_64/Python-3.7.1/Modules/_posixsubprocess.o
./build/python3/x86_64/Python-3.7.1/Modules/_posixsubprocess.c
./piles-ios/YourApp/__pycache__/subprocess.cpython-37.pyc
@s1113950 s1113950 changed the title Unable to import subprocess module Unable to use imported subprocess module May 18, 2019
@s1113950
Copy link
Author

I believe this is because of here: https://github.com/kivy/kivy-ios/blob/master/tools/templates/%7B%7B%20cookiecutter.project_name%20%7D%7D-ios/main.m#L158 does this mean that the subprocess module isn't designed to work with Kivy iOS apps? It works just fine when ran other ways.

@tito
Copy link
Member

tito commented Sep 16, 2019

What do you mean by other ways?
I put that because it didn't worked at all, but can be required on some imports (i don't remember which one)

@s1113950
Copy link
Author

It runs fine when run as python main.py for example, or when put on Android.

@Zen-CODE
Copy link
Member

Zen-CODE commented Sep 16, 2019

I'm pretty sure the multi-processing is not supported on iOS. I remember reading a more detailed article, but this link serves to confirm...
https://forum.omz-software.com/topic/4638/permission-error-with-multiprocessing-process

Multi-processing is something Apple deliberately tries to prevent. From the article below: "Despite iOS being a multitasking OS, it does not support multiple processes for one app."

https://medium.com/flawless-app-stories/basics-of-parallel-programming-with-swift-93fee8425287
[Updated] Gave wrong link above

@Zen-CODE
Copy link
Member

I'm taking the liberty of closing this as it's not a kivy issue. This seems to be a limitation inherent to iOS. Please feel free to re-open if there is any evidence to the contrary.

Thanks

tito added a commit that referenced this issue Sep 22, 2019
@tito
Copy link
Member

tito commented Sep 22, 2019

Just a note, simply importing asyncio (what kivy does in master) was using subprocess.PIPE.

@s1113950
Copy link
Author

I have a workaround for this:

# monkeypatching the things that asyncio needs
import subprocess
subprocess.PIPE = -1  # noqa
subprocess.STDOUT = -2  # noqa
subprocess.DEVNULL = -3  # noqa

I have this set right after my kivy.require statement at the top of my main.py file and things work fine for me. I'm using kivy v1.11.0.dev0, git-Unknown, 20190421 though, so not latest master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants