4

I'm trying to use PyInstaller v2.1 to create a single executable out of a simple hello world script (Python 2.7). The script, hello.py, has just one line:

print 'Hello, World!'

I then open a command window in the folder containing the script and enter:

pyinstaller -F hello.py

I get the following output:

C:\Users\chris\workspace\HelloPy>pyinstaller -F hello.py
43 INFO: wrote C:\Users\chris\workspace\HelloPy\hello.spec
66 INFO: Testing for ability to set icons, version resources...
79 INFO: ... resource update available
83 INFO: UPX is not available.
115 INFO: Processing hook hook-os
299 INFO: Processing hook hook-time
304 INFO: Processing hook hook-cPickle
402 INFO: Processing hook hook-_sre
585 INFO: Processing hook hook-cStringIO
721 INFO: Processing hook hook-encodings
741 INFO: Processing hook hook-codecs
1332 INFO: Extending PYTHONPATH with C:\Users\chris\workspace\HelloPy
1332 INFO: checking Analysis
1539 INFO: checking PYZ
1644 INFO: checking PKG
1655 INFO: building because C:\Users\chris\workspace\HelloPy\build\hello\hello.exe.manifest changed
1656 INFO: building PKG (CArchive) out00-PKG.pkg
7801 INFO: checking EXE
7803 INFO: rebuilding out00-EXE.toc because pkg is more recent
7803 INFO: building EXE from out00-EXE.toc
7809 INFO: Appending archive to EXE C:\Users\chris\workspace\HelloPy\dist\hello.exe

The build and dist folder are created as expected, as is the executable. I try to run it and get the following output:

C:\Users\chris\workspace\HelloPy>cd dist

C:\Users\chris\workspace\HelloPy\dist>hello
WARNING: file already exists but should not:      C:\Users\chris\AppData\Local\Temp\_MEI58962\include\pyconfig.h
Hello, World!

If I run pyinstaller instead without the single executable switch, i.e. without the -F then I don't get the "WARNING: file already exists"

I'm probably missing something really obvious but I've searched around and can't seem to find this problem anywhere else. Any help or a pointer to the solution elsewhere would be much appreciated.

Chris
  • 43
  • 6

1 Answers1

1

There was a ticket reported to the PyInstaller team here that points to this SO answer as a workaround: Pyinstaller --onefile warning pyconfig.h when importing scipy or scipy.signal

You modify your spec file with the following block under the a=Analysis line:

for d in a.datas:
    if 'pyconfig' in d[0]: 
        a.datas.remove(d)
        break

That should work for you as it seems to work for most.

Personally I prefer py2exe. Here is a link to a "Hello, World" example do to the exact same thing you are trying to achieve: http://www.py2exe.org/index.cgi/Tutorial

Community
  • 1
  • 1
Max Worg
  • 2,932
  • 2
  • 20
  • 35