How do you include subprocess with py2exe?

孤人 提交于 2019-12-12 03:35:55

问题


When I package my program into an exe using py2exe and try to run it, it comes back with the following:

Traceback (most recent call last):
  File "raman_utility_v1.0.2.pyw", line 386, in <module>
  File "raman_utility_v1.0.2.pyw", line 132, in __init__
  File "raman_utility_v1.0.2.pyw", line 136, in getHome
  File "subprocess.pyc", line 566, in check_output
  File "subprocess.pyc", line 710, in __init__
  File "subprocess.pyc", line 958, in _execute_child
WindowsError: [Error 2] The system cannot find the file specified

Currently my setup.py looks like this:

from distutils.core import setup
import py2exe

setup(
    options={
        "py2exe" : {"includes" : ["sip","subprocess"]}
    },
    windows=[{
        "script" : "raman_utility_v1.0.2.pyw"
    }]
)

And to run the setup.py, I run the following cmd:

python setup.py py2exe --includes sip

I have tried adding subprocess to the cmd like this:

python setup.py py2exe --includes sip,subprocess

but all that did was break sip.

I tried just copying the subprocess.pyc file into the dist folder, and that did not work. The last thing I tried was a suggestion from: py2exe not including the modules from "includes" which was to use "packages" instead of "includes" (for subprocess). That did not change anything. I also tried adding the line:

import subprocess

at the beginning of setup.py but that did not change anything either

Am I even on the right track? Any hints you have would be really helpful!

来源:https://stackoverflow.com/questions/36237678/how-do-you-include-subprocess-with-py2exe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!