Skip to main content

Posts

Showing posts with the label python

[raspbian] How To Install Python-3.6.11

Environment   raspbian: jessie   Linux phome 4.9.35-v7+ #1014 SMP Goal:   To setup Jupyter Notebook.   (needed pip3 18.1. (It required Python 3.5 but mine is 3.4.2) Conclusion:   - Python-3.6.11 : OK   - Python-3.8.3      make : OK, but pip cannot connect TLS/SSL       ( https://stackoverflow.com/questions/62827291/warning-pip-is-configured-with-locations-that-require-tls-ssl-however-the-ssl )      I think that it occurred by the difference of  openssl versions.      (But I did not to try figure out)    - Python-3.7.4 : Same problem like 3.8.3.    - Python-3.5.9 : Compile error by gcov dependency. Method:   - Download 3.6.11 source and compile.   - Type "make altinstall"   - Make file links with "update-alternatives" command.

[python] get string from output of other process

1.  The Script ---------------------------------- #!/usr/bin/python import subprocess def getCallResult(cmdARGS):   fd_popen = subprocess.Popen(cmdARGS.split(), stdout=subprocess.PIPE).stdout   data = fd_popen.read().strip()   fd_popen.close()   return data data = getCallResult("ls -la") print (data) ---------------------------------- 2. Result Example ---------------------------------- # python test.py total 524 drwxrwxr-x  4 parkmo parkmo   4096  1월 27 16:30 . drwxrwxr-x 45 parkmo parkmo   4096  1월 27 11:59 .. drw-rw-r--  1 parkmo parkmo    421  1월 27 12:01 test.py .. .. 1) If you don't want use split() when call subprocess.Popen, use [ ]. subprocess.Popen(["ls", "-la"], stdout=subprocess.PIPE).stdout 2) If you can want to file descriptor.   fd_popen = subprocess.Popen(cmdARGS.split(), stdout=subprocess.PIPE).wait() You can use Blocking or Non-Blocking. Test Environment: Pytho