Search code examples
pythonuser-interfacetkinterexesplinter

Why is 'splinter' module not found after creating python executable?


I created a small program in python using a few imports:

splinter, Tkinter, webbrwoser, urllib, and re

The program has a GUI (through tkinter), and everything works fine when I run it through the command line.

However, when I try to create an executable file using these instructions, everything seems to work but then when I actually run the .exe file, I get the following error:

C:\Python27\dist>pypy.exe
Traceback (most recent call last):
  File "pypy.py", line 1, in <module>
ImportError: No module named splinter

This is the code I used to get the .exe file:

from distutils.core import setup
import py2exe

setup(console=['pypy.py'])

So I'm guessing (after doing some reading in this SO post) the problem has something to do with missing files from my dist folder, but for the life of me I'm not sure where to go from here.

Please help me make my GUI python program work.

Thanks in advance,

Jona


Solution

  • ok! after quite a bit of digging (here, here, and here) I got it all to work!

    Steps:

    1. Copy the whole splinter folder to Python27\Lib\site-packages before running the setup.py
    2. Copy both "webdriver.xpi" and "webdriver_prefs.json" from C:\Python27\Lib\site-packages\selenium\webdriver\firefox to dist\selenium\webdriver\firefox after the setup (once the dist folder is created)
    3. Bonus: for the .exe to open without the console (good if you're using a GUI), in the setup.py file use windows instead of console in setup(console=['pypy.py'])

    And that's it! Now the program runs and works with the GUI and splinter libraries sans hitch!