Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyInstaller not working on simple HelloWorld Program

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?

like image 358
user1768884 Avatar asked Oct 07 '13 12:10

user1768884


People also ask

Why is my PyInstaller not working?

The most common reason a PyInstaller package fails is that PyInstaller failed to bundle a required file. Such missing files fall into a few categories: Hidden or missing imports: Sometimes PyInstaller can't detect the import of a package or library, typically because it is imported dynamically.

Do you need Python to run a PyInstaller EXE?

They do not need to have Python installed at all. The output of PyInstaller is specific to the active operating system and the active version of Python. This means that to prepare a distribution for: a different OS.


2 Answers

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.

like image 193
tul Avatar answered Sep 25 '22 02:09

tul


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à.

like image 31
ewerybody Avatar answered Sep 26 '22 02:09

ewerybody