I made an exe file with my Selenium parser. But there is a problem. When starting it gives the following error.
Traceback (most recent call last):
File "main.py", line 11, in <module>
File "fake_useragent\fake.py", line 56, in __init__
File "fake_useragent\utils.py", line 52, in load
fake_useragent.errors.FakeUserAgentError: ('Data list is empty', None)
Here are all the lines related to using fake_useragent:
from fake_useragent import FakeUserAgent
a = FakeUserAgent().random
options = webdriver.ChromeOptions()
options.add_argument(f'user-agent={a}')
How to fix this problem?
I used pyinstaller when creating the exe. I used this command:
pyinstaller ./main.py --onefile --noconsole --add-binary "./driver/chromedriver.exe;./driver"
The project structure is like this:
MyProj/
├ driver/
│ └ chromedriver.exe
└ main.py
When I remove the lines related to fake-useragent, the code works without errors.
Adding --hidden-import=fake_useragent didn't help.
What is the problem? Can I somehow change the exe creation command?