问题
I have written a (very simple) little Python script, and I want to be able to distribute it to friends who have no idea what Python is, nor anything about Windows cmd scripts. So, fundamentally I need to install Python on their systems, followed by installing the required libraries for my script, followed by my script (and appropriate start-up links in their desktop).
I have no interest in creating some sophisticated install program. So, I have written a very simple, trivial little cmd script to do the install (and created a self-extracting archive that runs the install script.)
In the archive, I have the internet-accessing install executables for installing Python. The script tests for an existing Python install, and when none is found, it installs Python. this works well.
But, after installing Python, I need to install some required modules/libraries that do not come pre-bundled with Python. It would be nice to be able to use pip3 to install these libraries. Fundamentally, this is what needs to be run:
python-3.8.2-webinstall.exe PrependPath=1
pip3 install --user requests python-dateutil pychromecast gtts
The problem here is that after the Python web install, the process (console process) running this script does not inherit the new settings (esp. the new path settings) from the web install process, and so the pip3
command fails.
My first attempt to remedy this was to use the console START command to start the pip3 command in a separate process that would have the new settings:
python-3.8.2-webinstall.exe PrependPath=1
START "PythonRequireds" /I /wait cmd /C "pip3 install --user requests python-dateutil pychromecast gtts"
From the documentation for the START command, I would have expected the /I option would ensure the started process had a new environment including the changes from the just-completed web install. Alas, it was not to be: the pip3 command was still not found.
So, my question: does anyone know how to start a new process from a Windows console script, so that the new process has all the changes to the path just placed in the registry by the install process?
来源:https://stackoverflow.com/questions/61473551/how-do-i-start-a-windows-7-console-with-a-newly-modified-system-environment