I am coding an install tool for python modules, for machines that aren't connected to the internet.
The idea is to first use the tool on a machine that has network access, and then use it on local machines.
To do that, I needed to call pip download from my script. I tried using this:
subprocess.run(['py','-m','pip','download','-r','C:/.../libs/Python 3.8/requirements.txt','-d','C:/.../libs/Python 3.8','--python-version','3.8','--only-binary=:all:'])
But I only got an error code claiming that the ssl module in Python is not available.
When used in the cmd, the command above is functional and pip doesn't complain about ssl.
I tried to check if the python I used in VSCode was different from the version in the cmd, but it doesn't seem so.
I looked around stackoverflow and I found this answer: https://stackoverflow.com/a/50255019/18027979.
I tried the following:
subprocess.check_call([sys.executable,'-m','pip','download','-r','C:/.../libs/Python 3.8/requirements.txt','-d','C:/.../libs/Python 3.8','--python-version','3.8','--only-binary=:all:'])
The ssl warning and connection timeout are still showing up, but the libs and their dependencies are successfully downloaded.
I know that the sys.executable
arg is checking that the call is using the pip that's currently on runtime, but I am unsure how this helps with the issues I encountered with the first command.