V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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 · 2019-01-31 15:58:12 +08:00 · 1915 次点击
    这是一个创建于 1904 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

    subprocess.run('python --version')

    是没有问题的,但是

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

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

    avatar

    2 条回复    2019-01-31 16:42:30 +08:00
    ysc3839
        1
    ysc3839  
       2019-01-31 16:34:08 +08:00 via Android   ❤️ 1
    https://bugs.python.org/issue18338
    Python 3.4 之前会把 version 输出到 stderr。
    sipangzi
        2
    sipangzi  
    OP
       2019-01-31 16:42:30 +08:00
    @ysc3839 谢谢大佬,明白了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3069 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 00:33 · PVG 08:33 · LAX 17:33 · JFK 20:33
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.