I'm trying to send command through socket with subprocess (python 2.7 (qpython android)).
here 's the code :
#reponse is my command
x = subprocess.Popen(reponse,
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
stdin=subprocess.PIPE)
y = str(x.stdout.read() + x.stderr.read())
But when i'm trying, i've got this error :
Traceback (most recent call last):
File "ser.py", line 72, in <module>
stdin=subprocess.PIPE)
File "/QPython/QPython2-core/build/python-install/lib/python2.7/subprocess.py",
line 679, in __init__
File "/QPython/QPython2-core/build/python-install/lib/python2.7/subprocess.py",
line 1228, in _execute_child
OSError: [Errno 2] No such file or directory
So, can someone tell me what's wrong, and how to fixe this .. Thx in advance for help...
I found that commands don't work if you specify shell=True.
I had the same error.
You should use the commands and its arguments as a list; i.e.:
your_cmd = ['examplecmd', '-a', 'foo', '-b', 'bar']
Related
Getting errors as below, when I follow step 4 of the instruction from Getting Started with ARC Open Source on Linux. OS is Ubuntu 14.04 LTS running in Hyper-V.
UBUNTU14:~/arc$ ./configure
ERROR:root:While running
['third_party/tools/depot_tools/third_party/gsutil/gsutil', 'cp',
'gs://arc-build/naclports/builds/pepper_40/python.zip',
'/tmp/tmpUZ0IoK/naclports-python'] ERROR:root:GSResponseError:
status=403, code=None, reason=Forbidden.
ERROR:root:Try prodaccess, and if it does not solve the problem try rm
~/.devstore_token ###STEP_WARNINGS### ERROR:root:Retrying after 9 s
sleeping Traceback (most recent call last): File
"/home/fkiller/arc/src/build/build_common.py", line 938, in wrapper
return func(*args, **kwargs) File "/home/fkiller/arc/src/build/util/download_package_util.py", line 243,
in _download_package_with_retries
self._download_method(url, download_package_path) File "/home/fkiller/arc/src/build/util/download_package_util.py", line 119,
in _download
build_common.get_gsutil_executable(), 'cp', url, destination_path]) File
"/home/fkiller/arc/src/build/util/download_package_util.py", line 97,
in execute_subprocess
output = subprocess.check_output(cmd, cwd=cwd, stderr=subprocess.STDOUT) File "/usr/lib/python2.7/subprocess.py",
line 573, in check_output
raise CalledProcessError(retcode, cmd, output=output) CalledProcessError: Command
'['third_party/tools/depot_tools/third_party/gsutil/gsutil', 'cp',
'gs://arc-build/naclports/builds/pepper_40/python.zip',
'/tmp/tmpUZ0IoK/naclports-python']' returned non-zero exit status 1
Any idea to resolve this without changing build script? I may manually pointing python.zip from other sources such as https://naclports.storage.googleapis.com/builds/pepper_40/trunk-147-g49eb4c9/publish/python/pnacl/python.zip, but I want to build it as is without changing scripts.
I've already tried to setup gsutil and its authenticator, but it didn't fix the issue.
EDIT: After #elijah-taylor fixed ACL, now I'm getting errors below
Traceback (most recent call last): File "src/build/configure.py",
line 365, in
sys.exit(main()) File "src/build/configure.py", line 347, in main
_gclient_sync_third_party() File "src/build/configure.py", line 132, in _gclient_sync_third_party
subprocess.check_output(cmd, cwd=os.path.dirname(gclient_filename)) File
"/usr/lib/python2.7/subprocess.py", line 566, in check_output
process = Popen(stdout=PIPE, *popenargs, **kwargs) File "/usr/lib/python2.7/subprocess.py", line 710, in init
errread, errwrite) File "/usr/lib/python2.7/subprocess.py", line 1327, in _execute_child
raise child_exception OSError: [Errno 2] No such file or directory
In the line 132,
File "src/build/configure.py", line 132, in _gclient_sync_third_party
subprocess.check_output(cmd, cwd=os.path.dirname(gclient_filename))
gclient_filename is "third_party/.gclient" and os.path.dirname(gclient_filename) is "thrid_party".
The problem was bad ACLs on the files. I reached out to #elijah-taylor for a fix, it should now work!
faced same issue..fixed after running the following.
apt-get install gsutil
apt-get install libwww-perl
chmod +x ./third_party/tools/depot_tools/third_party/gsutil/gsutil
I have created a pygame application. Now I want to create an APK and for that I need to install pygame_sdl2. However, when I try to install by running python setup.py install I get this error
Traceback (most recent call last):
File "C:\pygame_sdl2-master\setup.py", line 36, in <module>
parse_cflags([ "sh", "-c", "sdl2-config --cflags" ])
File "C:\pygame_sdl2-master\setuplib.py", line 93, in parse_cflags
output = subprocess.check_output(command, universal_newlines=True)
File "C:\Python27\lib\subprocess.py", line 566, in check_output
process = Popen(stdout=PIPE, *popenargs, **kwargs)
File "C:\Python27\lib\subprocess.py", line 710, in __init__
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 958, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
Any help in this context would be appreciated.
Download the version you need here https://bitbucket.org/marcusva/py-sdl2/downloads
Exctract, open the cmd and navigate to the folder.
Run python setup.py install
Working for me this way.I downloaded PySDL2-0.9.3.zip file
I'm currently trying to run the systrace python script that is included in the platform-tools folder and I'm getting the following error:
File "systrace.py", line 274, in <module>
main()
File "systrace.py", line 60, in main
device_sdk_version = get_device_sdk_version()
File "systrace.py", line 44, in get_device_sdk_version
stderr=subprocess.PIPE)
File "/usr/lib/python2.7/subprocess.py", line 679, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1249, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
I'M running on Ubuntu 12.04 LTS. Here is the command I'm using to run systrace:
sudo python systrace.py -o output.html
NOTE: The sudo is in order to avoid the following error:
File "systrace.py", line 274, in <module>
main()
File "systrace.py", line 63, in main
os.execv(legacy_script, sys.argv)
OSError: [Errno 13] Permission denied
After doing some searching around the web I found that one solution was to add the adb to my PATH variable. I added the platform-tools directory to my PATH and I'm still getting the same error. I went ahead to check the code that is causing the problem and apparently its this snippet:
adb = subprocess.Popen(getprop_args, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
where getprop_args is defined as follows:
getprop_args = ['adb', 'shell', 'getprop', 'ro.build.version.sdk']
From what I understand the code is trying to run the following command:
adb shell getprop ro.build.version.sdk
I ran the command in console and it work with no problem. I also copied both lines of code and ran them in python interpreter and it ran without a problem. I really don't know how to solve this issue. Does anyone know of a possible solution?
Ok so I found out what the problem was. The problem was the sudo that I was putting right before python systrace.py -o output.html I didn't know but I guess the PATH variable is different when using sudo, than when not using it. So the PATH in sudo didn't have the platform-tools directory. So I removed the sudo and I was getting the following error:
File "systrace.py", line 274, in <module>
main()
File "systrace.py", line 63, in main
os.execv(legacy_script, sys.argv)
OSError: [Errno 13] Permission denied
To solve this problem I ran the following command on the legacy_script:
$chmod +x ./systrace-legacy.py
And now I was able to run the systrace script without a problem :P
this problem is causing by PATH. adb path should put the end of the other path.
for example:
$ sudo gedit /etc/environment;
PATH="...:~/softAddr/adt-bundle-linux-x86_64-20140624/sdk/platform-tools:~/softAddr/adt-bundle-linux-x86_64-20140624/sdk/tools"
not:
PATH="~/softAddr/adt-bundle-linux-x86_64-20140624/sdk/platform-tools:~/softAddr/adt-bundle-linux-x86_64-20140624/sdk/tools:..."
I've followed the instructions Google has provided on downloading the Source Tree, but after I run the command
$ repo init -u https://android.googlesource.com/platform/manifest -b android-2.3.7_r1
and I receive the following error message :
$ repo init -u https://android.googlesource.com/platform/manifest -b android-2.3.7_r1
Traceback (most recent call last):
File "/Users/roboguy12/bin/repo", line 690, in <module>
main(sys.argv[1:])
File "/Users/roboguy12/bin/repo", line 657, in main_Init(args)
File "/Users/roboguy12/bin/repo", line 189, in _Init_CheckGitVersion()
File "/Users/roboguy12/bin/repo", line 214, in _CheckGitVersion
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 595, in __init__
errread, errwrite)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/subprocess.py", line 1106, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
What did I do wrong? Or is this just an error on behalf of Repo?
UPDATE: Now that I've installed Python 2.7, I still have almost the exact same error message:
$ repo init -u https://android.googlesource.com/platform/manifest -b android-2.3.7_r1
Traceback (most recent call last):
File "/Users/roboguy12/bin/repo", line 690, in <module>
main(sys.argv[1:])
File "/Users/roboguy12/bin/repo", line 657, in main_Init(args)
File "/Users/roboguy12/bin/repo", line 189, in _Init_CheckGitVersion()
File "/Users/roboguy12/bin/repo", line 214, in _CheckGitVersion
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 672, in __init__
errread, errwrite)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1202, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
I call $ python -V and it says Python 2.7.1, so I don't know what else I can do.
Seems to me you might have not done a couple of things: chmod'd the repo to +x and/or put it in your $PATH statement as the first directory to look for (and could be using another version of repo). Have you tried 'ls -al' instead? The directory you're looking for is hidden and you need the -a argument in ls to view hidden files/directories.
UPDATE: Ah, just saw your update. Since you're using a Mac, you need to use Python 2.7. To do so, you'll need to MacPort it. This website provided much help to me: INSTALLING PYTHON 2.7, EASY_INSTALL, PIP, VIRTUALENV AND VIRTUALENVWRAPPER ON MAC OS X
While initializing the repo to download Android Source Code using the following command -
repo init -u git://android.git.kernel.org/platform/manifest.git
I'm getting the following error -
Traceback (most recent call last):
File "/home/pritamn/bin/repo", line 603, in <module>
main(sys.argv[1:])
File "/home/pritamn/bin/repo", line 570, in main
_Init(args)
File "/home/pritamn/bin/repo", line 184, in _Init
_CheckGitVersion()
File "/home/pritamn/bin/repo", line 213, in _CheckGitVersion
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)
File "/usr/lib/python2.7/subprocess.py", line 672, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1201, in _execute_child
raise child_exception
Can anybody please help me in pin-pointing the exact cause of this error?
You must have git installed for that command to work
Do you have git installed? Make sure it's installed by typing "git" on the command line.
Running on Win7 64bit I had to add "C:\Program Files (x86)\Git\bin" to my PATH in order for this to work.
I had this happen to me, you need to apt-get remove git-core and re-install it using apt-get install git-core.