Reputation: 11
I wrote a small python program in 3.6 to automate a task I do monthly at work. It could be useful to other people I work with, so I've been trying to bundle it with Pynsist.
Before bundling, the program runs successfully both from IDLE and the windows command line. After bundling and installation via the .exe, I receive an error stating:
Traceback (most recent call last): File "C:\Program Files\Time Clocker\timeClocker.py", line 7, in from selenium import webdriver ModuleNotFoundError: No module named 'selenium'
Selenium isn't the first module that gets imported in my code, so it seems the others are being bundled correctly and the issue is just with selenium.
I've tried including some selenium files in a pynsist_pkgs folder, but that doesn't work either. Here are those files, not sure if they are the right ones.
04/04/2017 02:25 PM 19,057 CHANGES
03/08/2017 07:00 AM 915 MANIFEST.in
04/04/2017 02:28 PM 7,864 PKG-INFO
04/04/2017 08:11 AM 5,719 README.rst
04/13/2017 04:50 PM <DIR> selenium
04/13/2017 04:50 PM <DIR> selenium.egg-info
04/04/2017 02:28 PM 230 setup.cfg
04/04/2017 02:26 PM 3,806 setup.py
6 File(s) 37,591 bytes
Here is my installer.cfg file for reference:
[Application]
name=Time Clocker
version=1.0
package:
script=timeClocker.py
console=true
[Python]
version=3.6.1
[Include]
packages = selenium
re
getpass
files = chromedriver.exe
If anyone has any ideas, that would be greatly appreciated!
Upvotes: 1
Views: 144
Reputation: 40340
Reposting as an answer so it's clear to other people who come across this.
The installer.cfg file uses script=
to define how to launch the application. It's recommended to use entry_point=
instead to specify a function, like:
entry_point=my_module:main
The documentation has more info on what this does.
If you do need to use a script, make sure that it has some boilerplate at the top before it tries to import packages:
import sys
sys.path.insert(0, 'pkgs')
Using entry_point=
allows Pynsist to automatically add this boilerplate and more (e.g. to better handle uncaught exceptions in GUI apps). This is why I'd always recommend that over script=
. A future version of Pynsist may even remove the option to specify a script.
Upvotes: 1