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?

1
  • This problem doesn't occur in PyInstaller 3.4
    – alwbtc
    Apr 4, 2019 at 12:09

5 Answers 5

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
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 7, 2013 at 16:27
  • @dthor, did you ever get this resolved? I seem to be stuck the same place.
    – devanl
    Aug 28, 2014 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"]:
4
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.

2
  • your suggestion works on windows but fails on linux. just fyi.
    – R. Simac
    Apr 25, 2014 at 18:34
  • I'm not sure, but I don't think the problem would even happen on Linux, so you wouldn't need a solution. Have you had this problem on Linux?
    – scornwell
    May 1, 2014 at 21:26
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.

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

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.