25

This is very simple to recreate. If my script foo.py is:

import scipy

Then run:

python pyinstaller.py --onefile foo.py

When I launch foo.exe I get:

WARNING: file already exists but should not: C:\Users\username\AppData\Local\Temp\_MEI86402\Include\pyconfig.h

I've tested a few versions but the latest I've confirmed is 2.1dev-e958e02 running on Win7, Python 2.7.5 (32 bit), Scipy version 0.12.0

I've submitted a ticket with the Pyinstaller folks but haven't heard anything yet. Any clues how to debug this further?

Jonno
  • 767
  • 2
  • 7
  • 13

5 Answers5

21

You can hack the spec file to remove the second instance by adding these lines after a=Analysis:

for d in a.datas:
    if 'pyconfig' in d[0]: 
        a.datas.remove(d)
        break
Ilya Tolchinsky
  • 226
  • 1
  • 2
  • 1
    Sadly this workaround didn't work for me. It got rid of the "file already exists" error, but now the --onefile executable just crashes without any warning. I'll fiddle with it some more and see if I can't figure something out. – dthor Oct 07 '13 at 16:27
  • @dthor, did you ever get this resolved? I seem to be stuck the same place. – devanl Aug 28 '14 at 12:44
15

The answer by wtobia@ worked for me. See https://github.com/pyinstaller/pyinstaller/issues/783

  1. Go to C:\Python27\Lib\site-packages\PyInstaller\build.py
  2. Find the def append(self, tpl): function.
  3. Change if tpl[2] == "BINARY": to if tpl[2] in ["BINARY", "DATA"]:
frmdstryr
  • 20,142
  • 3
  • 38
  • 32
  • Worked like a charm for me! – pbreach Aug 12 '14 at 04:22
  • 1
    link is dead; perhaps see https://github.com/pyinstaller/pyinstaller/issues/783 instead – dak Aug 01 '15 at 21:56
  • It looks like this issue is fixed in the development version, but they haven't put out [a release](https://github.com/pyinstaller/pyinstaller/releases) since 2013. The workaround by [scornwell](http://stackoverflow.com/a/20695056/4794) worked for me. – Don Kirkby Aug 14 '15 at 17:54
  • This problem doesn't occur in PyInstaller 3.4 – alwbtc Apr 04 '19 at 07:09
7

Expanding upon Ilya's solution, I think this is a little bit more robust solution to modifying the spec file (again place after the a=Analysis... statement).

a.datas = list({tuple(map(str.upper, t)) for t in a.datas})

I only tested this on a small test program (one with a single import and print statement), but it seems to work. a.datas is a list of tuples of strings which contain the pyconfig.h paths. I convert them all to lowercase and then dedup. I actually found that converting all of them all to lowercase was sufficient to get it to work, which suggests to me that pyinstaller does case-sensitive deduping when it should be case-insensitive on Windows. However, I did the deduping myself for good measure.

scornwell
  • 268
  • 3
  • 4
1

I realized that the problem is that Windows is case-insensitive and these 2 statements are source directories are "duplicates: include\pyconfig.h Include\pyconfig.h

My solution is to manually tweak the .spec file with after the a=Analysis() call:

import platform
if platform.system().find("Windows")>= 0:
    a.datas = [i for i in a.datas if i[0].find('Include') < 0]

This worked in my 2 tests.

A more flexible solution would be to check ALL items for case-insensitive collisions.

Keven Webb
  • 11
  • 2
0

I ran the archive_viewer.py utility (from PyInstaller) on one of my own --onefile executables that has the same error and found that pyconfig.h is included twice:

 (31374007, 6521, 21529, 1, 'x', 'include\\pyconfig.h'),
 (31380528, 6521, 21529, 1, 'x', 'Include\\pyconfig.h'),
 (31387049, 984, 2102, 1, 'x', 'pytz\\zoneinfo\\CET'),

Sadly though, I don't know how to fix it.

PyInstaller Manual link: http://www.pyinstaller.org/export/d3398dd79b68901ae1edd761f3fe0f4ff19cfb1a/project/doc/Manual.html#archiveviewer

dthor
  • 1,749
  • 1
  • 18
  • 45