PyInstaller with Python 3.6 and PySide2 fails on Windows 10

Pyinstaller spits out warnings lthat it could not find libraries like api-ms-win-core-* and api-ms-win-crt-*. This leads to an executable working on windows 10, even on a new machine, but not on earlier versions as pyinstaller fails to bundle the needed files.

The fix is quite simple:

  1. Download Visual Studio 2017 community from microsoft website
  2. Install following components:
    Windows Universal CRT SDK
    Windows 8.1 SDK
    VC++ 2015.3 v140 toolset for desktop
    Windows Universal C Runtime
  3. When invoking pyinstaller use
    –path "C:\Program Files (x86)\Windows Kits\10\Redist\ucrt\DLLs\x86"

Done 🙂

well the path is for the 32bit libraries, guess what, replace DLLs\x86 with DLLs\x64 when using python 64bit

OR install Visual C++ 2017 Redist package on the destination machine.

If the packaged application still does not run please install the mentioned redist package

OOP in javascript

well explained public, private and protected variables and methods in javascript:

http://phrogz.net/js/classes/OOPinJS.html

function Person(n,race){ 
	this.constructor.population++;

	// ************************************************************************ 
	// PRIVATE VARIABLES AND FUNCTIONS 
	// ONLY PRIVELEGED METHODS MAY VIEW/EDIT/INVOKE 
	// *********************************************************************** 
	var alive=true, age=1;
	var maxAge=70+Math.round(Math.random()*15)+Math.round(Math.random()*15);
	function makeOlder(){ return alive = (++age <= maxAge) } 

	var myName=n?n:"John Doe";
	var weight=1;


	// ************************************************************************ 
	// PRIVILEGED METHODS 
	// MAY BE INVOKED PUBLICLY AND MAY ACCESS PRIVATE ITEMS 
	// MAY NOT BE CHANGED; MAY BE REPLACED WITH PUBLIC FLAVORS 
	// ************************************************************************ 
	this.toString=this.getName=function(){ return myName } 

	this.eat=function(){ 
		if (makeOlder()){ 
			this.dirtFactor++;
			return weight*=3;
		} else alert(myName+" can't eat, he's dead!");
	} 
	this.exercise=function(){ 
		if (makeOlder()){ 
			this.dirtFactor++;
			return weight/=2;
		} else alert(myName+" can't exercise, he's dead!");
	} 
	this.weigh=function(){ return weight } 
	this.getRace=function(){ return race } 
	this.getAge=function(){ return age } 
	this.muchTimePasses=function(){ age+=50; this.dirtFactor=10; } 


	// ************************************************************************ 
	// PUBLIC PROPERTIES -- ANYONE MAY READ/WRITE 
	// ************************************************************************ 
	this.clothing="nothing/naked";
	this.dirtFactor=0;
} 


// ************************************************************************ 
// PUBLIC METHODS -- ANYONE MAY READ/WRITE 
// ************************************************************************ 
Person.prototype.beCool = function(){ this.clothing="khakis and black shirt" } 
Person.prototype.shower = function(){ this.dirtFactor=2 } 
Person.prototype.showLegs = function(){ alert(this+" has "+this.legs+" legs") } 
Person.prototype.amputate = function(){ this.legs-- } 


// ************************************************************************ 
// PROTOTYOPE PROERTIES -- ANYONE MAY READ/WRITE (but may be overridden) 
// ************************************************************************ 
Person.prototype.legs=2;


// ************************************************************************ 
// STATIC PROPERTIES -- ANYONE MAY READ/WRITE 
// ************************************************************************ 
Person.population = 0;

Fixing PyInstaller on OSX when using PySide

When using PyInstaller to package my PySide application  i had following errors in the command-line:

3513 INFO: Looking for dynamic libraries
3663 ERROR: Can not find path ./libpyside-python2.7.1.2.dylib (needed by /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PySide/QtGui.so)
3664 ERROR: Can not find path ./libshiboken-python2.7.1.2.dylib (needed by /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PySide/QtGui.so)
3670 ERROR: Can not find path ./libpyside-python2.7.1.2.dylib (needed by /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PySide/QtNetwork.so)
3670 ERROR: Can not find path ./libshiboken-python2.7.1.2.dylib (needed by /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PySide/QtNetwork.so)
3680 ERROR: Can not find path ./libpyside-python2.7.1.2.dylib (needed by /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PySide/QtCore.so)
3680 ERROR: Can not find path ./libshiboken-python2.7.1.2.dylib (needed by /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PySide/QtCore.so)

My application did start on my own machine but not on others where PySide was not installed. Here is a simple fix which worked for me to get my app running on another mac:

Open following file:

/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PyInstaller/depend/bindepend.py

and look for the function _getImports_macholib()… inside that function find following loop:

# Try multiple locations.
for run_path in run_paths:
    # @rpath may contain relative value. Use exec_path as
    # base path.
    if not os.path.isabs(run_path):
        run_path = os.path.join(exec_path, run_path)
    # Stop looking for lib when found in first location.
    if os.path.exists(os.path.join(run_path, lib)):
        final_lib = os.path.abspath(os.path.join(run_path, lib))
        rslt.add(final_lib)
        break

and change the loop to

# Try multiple locations.
for run_path in run_paths:
    # @rpath may contain relative value. Use exec_path as
    # base path.
    if not os.path.isabs(run_path):
        run_path = os.path.join(exec_path, run_path)
    # Fix path problems for PySide install on OSX
    if "PySide" in run_path:
        run_path = run_path.replace("../../../", "") 
    # Stop looking for lib when found in first location.
    if os.path.exists(os.path.join(run_path, lib)):
        final_lib = os.path.abspath(os.path.join(run_path, lib))
        rslt.add(final_lib)
        break

That's it, save the file and package your app. For me that fixed all other errors.

Here my setup when fixing: PySide 1.2.4 (PyPi), Qt 4.8.7 (stock binary), Python 2.7.12, PyInstaller 3.3-dev

Happy coding.