I have a Python script that I'm trying to convert to an executable so that other computers can use it without Python installed. I've been trying to use PyInstaller but I keep running into issues and I think its because I have the Selenium module installed. I found this link from a couple months ago and I tried following what the user did, except with Firefox and not Chrome, but my program still won't work as an executable. My program will end/crash when Firefox is supposed to open.
This is the .spec file I made following the answer in the post above, as well as the users comments that he claims worked:
# -*- mode: python -*-
block_cipher = None
a = Analysis(['main.py'],
pathex=['C:\\Users\\Matthew\\Desktop\\Python'],
binaries=[('C:\\Python\\browserdriver\\geckodriver.exe' , '.')],
datas=[],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
exclude_binaries=True,
name='Work Bot v1.5',
debug=False,
strip=False,
upx=True,
console=True )
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
name='main')
Here are the relevant lines in my Python script:
path = os.path.join(sys._MEIPASS, "geckodriver")
driver = webdriver.Firefox(path)
Any help is greatly appreciated!
EDIT:
After running the program in Command Prompt, I got to see the error before the program crashes:
Traceback (most recent call last):
File "main.py", line 404, in <module>
File "site-packages\selenium\webdriver\firefox\webdriver.py", line 147, in __init__
File "site-packages\selenium\webdriver\firefox\firefox_profile.py", line 78, in __init__
File "shutil.py", line 309, in copytree
FileNotFoundError: [WinError 3] The system cannot find the path specified: 'C:\\Users\\Matthew\\Desktop\\Python\\dist\\main\\geckodriver'
[3056] Failed to execute script main