I have a script that is set up to install dependencies if they are not already installed. The code for this is below:
import importlib
try:
importlib.import_module('selenium')
importlib.import_module('win32com.client')
importlib.import_module('keyboard')
except ImportError:
import pip
pip.main(['install', 'selenium', '--trusted-host'])
pip.main(['install', 'pypiwin32' '--trusted-host'])
pip.main(['install', 'keyboard', '--trusted-host'])
finally:
globals()['selenium'] = importlib.import_module('selenium')
globals()['win32com.client'] = importlib.import_module('win32com.client')
globals()['keyboard'] = importlib.import_module('keyboard')
This works fine on my computer and several of my colleagues', but the rest of my team (on the same network at the same location) can't get this to run. The issue appears to be with pip at first -- it throws an SSL error even when called directly from the command line with "pip install selenium" (and even with "pip install --trusted-host pypi.python.org"):
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certification verify failed (_ssl.c:833)'),)': /simple/selenium
I found this post which led me to try the --trusted-host solution without success. I checked C:Program Data/ and there was no "pip" folder there, so I created one and created a pip.ini config file. (NOTE: There was no config file at the user level either. I confirmed Pip was installed).
In the pip.ini file I copy/pasted the solution from that thread:
[global]
trusted-host pypi.python.org
pypi.org
files.pythonhosted.org
Now I get the error:
configparser.ParsingError: Source contains parsing errors: 'C:\\ProgramData\\pip\\pip.ini'
[line 2]: 'trusted-host pypi.python.org\n'
[line 3]: etc etc etc
[line 4]: etc etc etc
To see if I could bypass this process, I used easy_install to install selenium (successfully) but it was unable to locate pywin32. It found keyboard but when running setup.py for that module it gave me an error "No such file or directoyr: 'CHANGES.md'.
To summarize my questions:
Why would there be differences between computers on the same network in being able to use pip and access pypi.python.org? (Additionally, does the absence of pip folders and pip.ini files with the default installation raise any red flags?)
Why is "pip install --trusted-host pypi.python.org selenium" failing?
What is going wrong with my config file parsing?
Is there a reason easy_install cannot find pywin32?