推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
sipangzi
V2EX  ›  Python

subprocess 执行的命令中包含文件路径的问题

  •  
  •   sipangzi · Jan 31, 2019 · 2759 views
    This topic created in 2671 days ago, the information mentioned may be changed or developed.

    用 subprocess 获取执行路径的 python 版本,然后我就用 subprocess 去执行指定路径的 python --version 但是返回的结果不在 stdout 中,却在 stderr 中,直接执行

    subprocess.run('python --version')

    是没有问题的,但是

    subprocess.run('/a/c/c/python --version')

    输出结果就在 stderr 中了,感觉是路径导致的问题。macos+python3.7

    avatar

    2 replies    2019-01-31 16:42:30 +08:00
    ysc3839
        1
    ysc3839  
       Jan 31, 2019 via Android   ❤️ 1
    https://bugs.python.org/issue18338
    Python 3.4 之前会把 version 输出到 stderr。
    sipangzi
        2
    sipangzi  
    OP
       Jan 31, 2019
    @ysc3839 谢谢大佬,明白了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3509 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 11:15 · PVG 19:15 · LAX 04:15 · JFK 07:15
    ♥ Do have faith in what you're doing.