I have a problem when creating an exe file from my Python script using PyInstaller.

Script is working just fine when I run it from VS but once packed into exe file I get the following message when trying to run the app:

Traceback (most recent call last):
  File "final02.py", line 11, in <module>
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
    exec(bytecode, module.__dict__)
  File "selenium\webdriver\__init__.py", line 18, in <module>
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
    exec(bytecode, module.__dict__)
  File "selenium\webdriver\firefox\webdriver.py", line 29, in <module>
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
    exec(bytecode, module.__dict__)
  File "selenium\webdriver\remote\webdriver.py", line 27, in <module>
  File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_86\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
    exec(bytecode, module.__dict__)
  File "selenium\webdriver\remote\remote_connection.py", line 24, in <module>
ModuleNotFoundError: No module named 'urllib3'
[16444] Failed to execute script final02

To pack the app I have used following command:

pyinstaller.exe --onefile --icon=app.ico final02.py 

I have tried to include

 --hidden-import urllib3

but there I had no success.

Also it's worth mentioning that when running it form VS I have installed and successfully imported urllib3 module in my script where it works just fine.

0 Answers