Python Forum
PyInstaller not picking up selenium and urllib3
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PyInstaller not picking up selenium and urllib3
#1
Hello World,
Smile
I am having a problem when generating exe file using PyInstaller.
This is the command that I run to generate an executable : pyinstaller.exe --onefile --icon=01.ico -- myscript.py

I have tried to add hidden-import selenium and hidden-import urllib3 but still here is an error message that I am getting:
Error:
Traceback (most recent call last): File "myscript.py", line 11, in <module> File "C:\Users\username\AppData\Roaming\Python\Python36\site-packages\selenium\webdriver\__init__.py", line 18, in <module> from .firefox.webdriver import WebDriver as Firefox # noqa File "C:\Users\username\AppData\Roaming\Python\Python36\site-packages\selenium\webdriver\firefox\webdriver.py", line 29, in <module> from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver File "C:\Users\username\AppData\Roaming\Python\Python36\site-packages\selenium\webdriver\remote\webdriver.py", line 27, in <module> from .remote_connection import RemoteConnection File "C:\Users\username\AppData\Roaming\Python\Python36\site-packages\selenium\webdriver\remote\remote_connection.py", line 24, in <module> import urllib3 ModuleNotFoundError: No module named 'urllib3' [1616] Failed to execute script final02
btw script is working without any problems when running from VS.

Thanks
Reply
#2
Try using the auto-py-to-exe
https://www.youtube.com/watch?v=OZSZHmWSOeM
I'm just an osu!addict and degenerate who happens to like programming.
Reply
#3
Nope... still not working
Reply
#4
(Apr-26-2019, 11:08 AM)davork Wrote: This is the command that I run to generate an executable : pyinstaller.exe --onefile --icon=01.ico -- myscript.py
After you use this command pyinstaller.exe --onefile --icon=01.ico myscript.pyyou will get a myscript.spec file.
Edit the spec file to explicitly add hidden imports
then use pyinstaller.exe --onefile --icon=01.ico myscript.spec
https://pythonhosted.org/PyInstaller/spec-files.html
by the way you may include also the icon in the spec file
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#5
@buran when I populate this part of my spec file like this "hiddenimports=[urllib3]" and after I save it and run a pyinstaller.exe --onefile --icon=01.ico myscript.spec I get message "NameError: name 'urllib3' is not defined"
Reply
#6
it should be hiddenimports=['urllib3']
or you can add --hidden-import=urllib3 option on the CLI
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020