Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error while executing my .exe made with pyinstaller

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 ? :)

like image 704
Quentin Moreau Avatar asked Dec 31 '25 07:12

Quentin Moreau


1 Answers

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"
like image 189
MSTECH Avatar answered Jan 02 '26 19:01

MSTECH



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!