【问题标题】:Python Error The _posixsubprocess module is not being usedPython 错误 _posixsubprocess 模块没有被使用
【发布时间】:2012-09-20 07:53:38
【问题描述】:

您好,我通过 python 包装器运行带有线程的子进程,当我使用子进程模块时收到以下警告。

“_posixsubprocess 模块没有被使用,如果你的程序使用线程,子进程的可靠性可能会受到影响。”

这是什么意思? 我怎样才能摆脱它?

【问题讨论】:

    标签: python multithreading


    【解决方案1】:

    取消设置 PYTHONHOME 已为我解决了这个问题。

    【讨论】:

      【解决方案2】:

      我在使用 conda 安装的工具时遇到了同样的问题。原来有一种来自 pip 的 subprocess32 的冲突版本。运行它就可以了:

      pip uninstall subprocess32
      conda install -c conda-forge subprocess32 
      

      【讨论】:

        【解决方案3】:

        检查你是否可以手动import _posixsubprocess,子进程尝试在它的代码中导入这个,如果它产生异常,就会产生这个警告。

        【讨论】:

        • 不,我不能......我在哪里可以找到该模块?我已经搜索过它,但无法找到它。
        • 您运行的是什么操作系统?您是从存储库还是从源代码构建获得 Python?
        • 这样就解决了问题。我现在已请求安装该模块。谢谢。
        • 链接@avasal 是否已过时?我看到一个空白的 Google 代码页面。你是如何解决这个问题的?Pablo Jomer?
        【解决方案4】:

        我的解决方案是执行以下操作:

        pip uninstall subprocess32
        pip install -U subprocess32
        

        最初,当我尝试导入 matplotlib 时收到警告:

        Python 2.7.13 (default, May 16 2017, 12:02:12) 
        [GCC 6.2.0 20160901] on linux2
        Type "help", "copyright", "credits" or "license" for more information.
        >>> import matplotlib
        /home/methuselah/.local/lib/python2.7/site-packages/subprocess32.py:472: RuntimeWarning: The _posixsubprocess module is not being used. Child process reliability may suffer if your program uses threads.
          "program uses threads.", RuntimeWarning)
        >>>
        

        重新安装subprocess32后,警告消失:

        Python 2.7.13 (default, May 16 2017, 12:02:12) 
        [GCC 6.2.0 20160901] on linux2
        Type "help", "copyright", "credits" or "license" for more information.
        >>> import matplotlib
        >>> 
        

        【讨论】:

          【解决方案5】:

          如果您使用的 Python 版本不止一个,则可能是这样。 您需要为每个程序指定正确的 python 版本。 例如,我需要用于 miniconda 的 python 3.7,但 mendeleydesktop 声称此版本存在问题:

          _posixsubproces 及其位置也有问题

          所以我没有只在 phyton 环境中运行程序,而是使用 python2.7,它解决了这个问题。 希望能帮助到你。 干杯, 弗洛尔

          【讨论】:

            猜你喜欢
            • 2018-02-03
            • 2020-08-11
            • 2020-09-14
            • 2021-04-07
            • 1970-01-01
            • 2019-10-09
            • 2020-03-20
            • 2014-07-23
            • 2019-07-09
            相关资源
            最近更新 更多