Frage

So I am running on 64-bit Windows 7, and I set up Pyinstaller with Pip and PyWin32. I have python 2.7.

I made a simple hello world Program with this code

print "hello world!"

I put the file in the same directory as PyInstaller, and ran this code in the command prompt

pyinstaller.py helloWorld.py

Yet, when I try that, I get this error message:

Error loading Python DLL: C:\PROGRA~1\PYINST~1.1\build\HELLOW~1\python27.dll (error code 126)

What am I doing wrong and how do I fix this?

War es hilfreich?

Lösung

Run with the -F flag to produce the standalone exe:

pyinstaller -F helloworld.py

It will output to dist/helloworld.exe

NOTE this is a different location to when -F is not used, be sure to run the right exe afterwards.

Andere Tipps

Thanks @tul! My version of pyinstaller put it to dist\helloworld.exe though!

If you start it from C:\Python27\Scripts... that'll be C:\Python27\Scripts\dist... as well!

But whereever you have it, I recommend putting a batch file next to your .py to be able recompile any time with just a click:

I set it up so there is nothing but the .exe at the .py location and the temporary stuff goes to the temp dir:

@echo off
:: get name from filename without path and ext
set name=%~n0
echo ========= %name% =========

:: cut away the suffix "_build"
set name=%name:~0,-6%
set pypath=C:\Python27\Scripts
set buildpath=%temp%

if not exist %name%.py (
    echo ERROR: "%name%.py" does not exist here!
    pause
    exit /b
)

%pypath%\pyinstaller.exe --onefile -y %~dp0%name%.py --distpath=%~dp0 --workpath=%buildpath% --specpath=%buildpath%

I name it like the .py file plus "_build" and cut away the suffix in the batch script again. Voilà.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top