Python file to exe not working in all locations in my computer only works in dist folder in python installation

时间:2015-04-23 05:41:45

标签: python exe py2exe

I have created an exe file from python file which is add.py in my case, I followed this tutorial Tutorial

My setup.txt file as follows:

from distutils.core import setup
import py2exe

setup(console=['add.py'])
setup(options = { "py2exe": {"includes": ["encodings"]}})

The following is my exe creation step:

exe creation CMD

I got output exe file which is add.exe in this location C:\Python34\dist. I double clicked it and it is working. When I move that add.exe to another location suppose C:\Python34 or Any other location in my system it is not working. It is giving the following error instead of executing:

image

I do not have any idea why it is misbehave like this way. I need that exe file to work all my locations. How can I solve this? Any help will be appreciated!!

1 个答案:

答案 0 :(得分:2)

setup(
    console=['add.py'], 
    options = { 
        "py2exe": {
              "includes": ["encodings"], 
              "bundle_files": 1, 
              "ascii": False
         }
    }, 
    zipfile = None
)