2

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
4
  • This is a single file or single dir bundle? Commented Jun 27, 2018 at 17:09
  • Shouldn't it be path = os.path.join(sys._MEIPASS, "geckodriver.exe") Commented Jun 27, 2018 at 17:29
  • For some reason it produces the same result if I try to make it a single file or a single directory, if that's what you're asking. I'll try changing the path. Commented Jun 27, 2018 at 19:09
  • Did you try with .exe extension? Commented Jun 27, 2018 at 19:10

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.