Hi,
You might want to freeze your script into a standalone executable to run on any system without the need of installing python
or face_recognition
and maybe you want to create a demo for your application and want to give it to someone else without giving your source code. Here is a simple tutorial to do that. I tested this method with python3.6
on Windows 10, but I think you can get it working on Linux with a similar method.
face_recognition
and dlib
and you see no error when importing them into your script.python yourscript.py
.pip
:pip install pyinstaller
myproject
and myscript.py
face_recognition_models
and scipy-extra-dll
from your python installed directory to your project directory.<yourscriptname>.spec
like myscript.spec
next to your python script.<>
tag)# -*- mode: python -*-
block_cipher = None
face_models = [
('.\\face_recognition_models\\models\\dlib_face_recognition_resnet_model_v1.dat', './face_recognition_models/models'),
('.\\face_recognition_models\\models\\mmod_human_face_detector.dat', './face_recognition_models/models'),
('.\\face_recognition_models\\models\\shape_predictor_5_face_landmarks.dat', './face_recognition_models/models'),
('.\\face_recognition_models\\models\\shape_predictor_68_face_landmarks.dat', './face_recognition_models/models'),
]
a = Analysis(['<your python script name.py>'],
pathex=['<path to working directory>'],
binaries=face_models,
datas=[],
hiddenimports=['scipy._lib.messagestream', 'scipy', 'scipy.signal', 'scipy.signal.bsplines', 'scipy.special', 'scipy.special._ufuncs_cxx',
'scipy.linalg.cython_blas',
'scipy.linalg.cython_lapack',
'scipy.integrate',
'scipy.integrate.quadrature',
'scipy.integrate.odepack',
'scipy.integrate._odepack',
'scipy.integrate.quadpack',
'scipy.integrate._quadpack',
'scipy.integrate._ode',
'scipy.integrate.vode',
'scipy.integrate._dop', 'scipy._lib', 'scipy._build_utils','scipy.__config__',
'scipy.integrate.lsoda', 'scipy.cluster', 'scipy.constants','scipy.fftpack','scipy.interpolate','scipy.io','scipy.linalg','scipy.misc','scipy.ndimage','scipy.odr','scipy.optimize','scipy.setup','scipy.sparse','scipy.spatial','scipy.special','scipy.stats','scipy.version'],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
a.datas += Tree('./scipy-extra-dll', prefix=None)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
name='<your python script name>',
debug=False,
strip=False,
upx=True,
runtime_tmpdir=None,
console=True )
python -m pyinstaller myscript.spec
dist
directory.Thanks to @ageitgey and @davisking for their awesome work.
PascPeli, hbeyan, alexpardede, MrYZD, rezayoga and 15 morefordffx, sandip-narwade, Legorooj, saadi-tech and ismam3sandip-narwade, Legorooj, taufardh and ismam3davisking, hanyh0807, mariocesarc, mostafazaghlol, amanbadal890 and 7 moresandip-narwade, Legorooj, taufardh, saadi-tech, ismam3 and 1 moresandip-narwade, Legorooj and saadi-tech
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4