5

I'm trying to run a python file on a system without python installed. I'm using py2exe, which gives me a .pyc file which runs fine on my system, but when I give it to a friend without python it tells him Windows can't run the file.

My setup.py file contains this;

from distutils.core import setup
import py2exe

setup(console=['PyVersionControl.py'])

When I run py2exe in the commandline, this is output

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\chdick>python setup.py py2exe
running py2exe

  3 missing Modules
  ------------------
? readline                            imported from cmd, code, pdb
? win32api                            imported from platform
? win32con                            imported from platform
Building 'dist\PyVersionControl.exe'.
Building shared code archive 'dist\library.zip'.
Copy c:\windows\system32\python34.dll to dist
Copy C:\Python34\DLLs\pyexpat.pyd to dist\pyexpat.pyd
Copy C:\Python34\DLLs\_ctypes.pyd to dist\_ctypes.pyd
Copy C:\Python34\DLLs\unicodedata.pyd to dist\unicodedata.pyd
Copy C:\Python34\DLLs\_hashlib.pyd to dist\_hashlib.pyd
Copy C:\Python34\DLLs\_socket.pyd to dist\_socket.pyd
Copy C:\Python34\DLLs\_tkinter.pyd to dist\_tkinter.pyd
Copy C:\Python34\DLLs\_bz2.pyd to dist\_bz2.pyd
Copy C:\Python34\DLLs\select.pyd to dist\select.pyd
Copy C:\Python34\DLLs\_ssl.pyd to dist\_ssl.pyd
Copy C:\Python34\DLLs\_lzma.pyd to dist\_lzma.pyd
Copy DLL C:\Python34\DLLs\tk86t.dll to dist\
Copy DLL C:\Python34\DLLs\tcl86t.dll to dist\

C:\Users\chdick>
CDickson
  • 195
  • 2
  • 5
  • 15
  • 2
    Have you checked [this](http://stackoverflow.com/questions/26875291/py2exe-missing-modules)? – kstenger Apr 30 '15 at 16:10
  • 1
    Well, the point of `py2exe` is to create `.exe` objects. If you are only giving your friend `.pyc` objects, then yeah, there is no way for them to run it without Python installed. – John Y Apr 30 '15 at 16:13

2 Answers2

2

You need to use py2exe to create an executable file from your script (i.e. create script.exe from script.py).

If you have the correct version of py2exe installed, you should be able to type python -m py2exe.build_exe script.py.

See the py2exe package page for details.

Tim Henigan
  • 60,452
  • 11
  • 85
  • 78
  • I can make the file using py2exe now, but it gives a .pyc file and not a .exe file, which I can't run without python on my system, which I thought was the whole point of py2exe? – CDickson Apr 30 '15 at 20:03
  • @CDickson: The output, if completed without error, should be an exe file. Is there a `dist` folder after you run `py2exe`? If so, the exe should be found there. – Tim Henigan Apr 30 '15 at 20:39
  • Ah, I think I found it! Do I need everything in the `dist` folder, or just the library .zip and the exe? – CDickson May 01 '15 at 07:58
  • @CDickson: It depends on how you built the executable. For more info, review the docs for the [`--bundle-files`](https://pypi.python.org/pypi/py2exe/#the-bundle-files-option-explained) option. – Tim Henigan May 01 '15 at 14:44
-2

Py2exe doesn't support Python 3.4.

The title tells you that, it is only for the second version of Python.

Paco
  • 4,520
  • 3
  • 29
  • 53
Q-bart
  • 1,503
  • 4
  • 22
  • 41