sys.path.insert(0, path) where path is the path to the module to be load or call without going through environment variable or the need to have it defined. The module structure is as follows:caris\__init__.py_py_caris.pydcaris\__pycache__\......caris\bathy\.....caris\coverage\....caris\ui\....
"C:\Program Files\Python35\Scripts\pyinstaller.exe" -n "Point Cloud" --clean -y ^ -c --debug=imports ^ --exclude-module=caris ^ --add-data="ReadAPointCloudFromAPLYFileExample_01.png;." ^ ^ --icon=Point_Cloud.ico ^ PC.py
import search # PyInstaller PYZ
# caris not found in PYZ
# bytecode is stale for 'caris'
# code object from C:\Program Files\CARIS\BASE Editor\5.3\python\3.5\caris\__init__.py
# caris._py_caris not found in PYZ
Traceback (most recent call last):
File "PC.py", line 19, in <module>
File "<frozen importlib._bootstrap>", line 968, in _find_and_load
File "<frozen importlib._bootstrap>", line 957, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "c:\program files\python35\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 623, in exec_module
exec(bytecode, module.__dict__)
File "search.py", line 7, in <module>
File "<frozen importlib._bootstrap>", line 968, in _find_and_load
File "<frozen importlib._bootstrap>", line 957, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 697, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "C:\Program Files\CARIS\BASE Editor\5.3\python\3.5\caris\__init__.py", line 15, in <module>
from ._py_caris import *
File "<frozen importlib._bootstrap>", line 968, in _find_and_load
File "<frozen importlib._bootstrap>", line 957, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
File "<frozen importlib._bootstrap>", line 577, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 938, in create_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
ImportError: DLL load failed: Impossível localizar o procedimento especificado.
[9712] Failed to execute script PC
sys.path.insert in your PC.py? In which case that isn't enough for PyInstaller to find and bundle it properly.
I believe you can't do this using the command line. Run your bat file once. It should create a file called PC.spec. In it is all the information you would normally pass via command line arguments. To build you can just callPyInstaller PC.specrather than running your bat file in future.
Now to modify the build you should modify the spec file. In your spec there should be an argument `pathex=["folder/containing/your/script"]`. Add "C:/Program Files/CARIS/BASE Editor/5.3/python/3.5/" to that list noting the use of /s rather than \s in the path.
That should do it.
Brénainn
# -*- mode: python ; coding: utf-8 -*-
block_cipher = None
a = Analysis(['PC.py'],
pathex=['D:\\Python\\Novo\\Point Cloud Ver2','C:\\Program Files\\CARIS\\BASE Editor\\5.3\\python\\3.5'],
binaries=[],
datas=[('ReadAPointCloudFromAPLYFileExample_01.png', '.')],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=['caris'],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
[('v', None, 'OPTION')],
exclude_binaries=True,
name='Point Cloud',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=True , icon='Point_Cloud.ico')
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
upx_exclude=[],
name='Point Cloud')
--exclude-module=carisimport search # PyInstaller PYZ
# caris not found in PYZ
# bytecode is stale for 'caris'
# code object from C:\Program Files\CARIS\BASE Editor\5.3\python\3.5\caris\__init__.py
# caris._py_caris not found in PYZ
sys.path.insert(0, path)` line at the top of your spec file, before the `a = Analysis(...)` bit._call_with_frames_removed
ImportError: DLL load failed: Impossível localizar o procedimento especificado.
executable to find and interact with the Caris installation at run time
I'd maybe try finding and running Caris's python interpreter and see if what it's loading (using sys.modules)
import sys
sys.path.insert(0, "C:/Program Files/CARIS/BASE Editor/5.3/python/3.5/")
import caris
print(sys.modules.keys())
sys.path.insert(0, "C:/Program Files/CARIS/BASE Editor/5.3/python/3.5/caris")
import search # PyInstaller PYZ# caris not found in PYZTraceback (most recent call last): File "PC.py", line 19, in <module> File "<frozen importlib._bootstrap>", line 968, in _find_and_load File "<frozen importlib._bootstrap>", line 957, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 673, in _load_unlocked File "c:\program files\python35\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 623, in exec_module exec(bytecode, module.__dict__) File "search.py", line 7, in <module> File "<frozen importlib._bootstrap>", line 968, in _find_and_load File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlockedImportError: No module named 'caris'[7940] Failed to execute script PCimport carisfrom caris.coverage import *