Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/326.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过批处理脚本安装带有路径变量的python_Python_Python 3.x_Batch File_Path - Fatal编程技术网

通过批处理脚本安装带有路径变量的python

通过批处理脚本安装带有路径变量的python,python,python-3.x,batch-file,path,Python,Python 3.x,Batch File,Path,我正在尝试通过批处理脚本以编程方式安装python和1 pypi模块,以允许我在几台PC上运行我编写的需要该模块的脚本。批处理脚本将使安装更容易。我试过了 \\server\share\python-3.6.1.exe /quiet InstallAllUsers=1 Include_pip=1 Include_test=0 PrependPath=1 python -m pip install utm pause 没有成功。运行时,会抛出错误“python”未被识别

我正在尝试通过批处理脚本以编程方式安装python和1 pypi模块,以允许我在几台PC上运行我编写的需要该模块的脚本。批处理脚本将使安装更容易。我试过了

    \\server\share\python-3.6.1.exe /quiet InstallAllUsers=1 Include_pip=1 Include_test=0 PrependPath=1
    python -m pip install utm
    pause 

没有成功。运行时,会抛出错误
“python”未被识别为内部或外部命令
。我意识到这意味着系统路径变量没有正确更新,但我认为
PrependPath=1
正确设置了这些变量。任何人能提供的任何帮助都将不胜感激

PrependPath
将添加到路径中,您必须重新读取路径才能使命令正常工作

您可以使用重新读取路径,或者只需自定义安装路径,然后将完整路径传递给Python可执行文件,如下所示:

\\server\share\python-3.6.1.exe /quiet InstallAllUsers=1 TargetDir=%ProgramFiles%\Python3.6 Include_pip=1 Include_test=0 PrependPath=1
%ProgramFiles%\Python3.6\python.exe -m pip install utm

您必须关闭
cmd
并打开
cmd
的新实例才能获得新的路径值。这几乎奏效了。但是,它在
C:\program\
中安装了python,并向我提供了错误消息
C:\program不是可识别的命令。您可以尝试通过PowerShell运行该命令,或者只需使用非间隔路径,如
TargetDir=C:\Python\Python3.6
谢谢!我真的很感激。今晚晚些时候我会测试它,然后标记它为已解决。像一个符咒一样工作。非常感谢您的帮助。或者只需添加所需的引号,例如
设置“TARGETDIR=%ProgramFiles%\Python3.6”
并安装到
TARGETDIR=“%TARGETDIR%””
并运行
%TARGETDIR%\python.exe”-m pip install utm