I made a little program that uses selenium web driver in python. My program works fine when running on spyder. Then i use pyinstaller to do the exe
pyinstaller ./main.py --onefile --noconsole --add-binary "./driver/chromedriver.exe;./driver"
But then can't launch it, I got this error
Traceback (most recent call last):
File "noto.py", line 8, in <module>
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
File "selenium\webdriver\__init__.py", line 18, in <module>
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
File "selenium\webdriver\firefox\webdriver.py", line 29, in <module>
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
File "selenium\webdriver\remote\webdriver.py", line 26, in <module>
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 631, in exec_module
File "selenium\webdriver\remote\webelement.py", line 43, in <module>
File "pkgutil.py", line 637, in get_data
File "PyInstaller\loader\pyimod03_importers.py", line 479, in get_data
FileNotFoundError: [Errno 2] No such file or
directory:'C:\\Users\\Mon nom\\AppData\\Local\\Temp\\1\\_MEI50482\\
selenium\\webdriver\\remote\\getAttribute.js'
[28052] Failed to execute script 'noto' due to unhandled exception!
So indeed, I don't have this directory because selenium is installed in this path: C:\Users\Mon nom\Anaconda3\Lib\site-packages\selenium\webdriver\remote and i have the getAttribute.js file.
Does somebody have an idea ? :)
just add
--collect-data selenium
option to your pyinstaller command line,
so it should be like:
pyinstaller ./main.py --collect-data selenium --onefile --noconsole --add-binary "./driver/chromedriver.exe;./driver"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With