Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function GetPythonVersion()
- On Error Resume Next
- Err.Clear
- GetPythonVersion = vbNullString
- Set WshShell = CreateObject("WScript.Shell")
- Set WshExec = WshShell.Exec("python --version")
- If Err.Number = 0 Then ' если питон вообще есть
- Set TextStream = WshExec.StdOut
- Str = vbNullString
- While Not TextStream.AtEndOfStream
- Str = Str & Trim(TextStream.ReadLine()) & vbCrLf
- Wend
- Set objRegExp = CreateObject("VBScript.RegExp")
- objRegExp.Pattern = "(\d+\.?)+"
- objRegExp.Global = True
- Set objMatches = objRegExp.Execute(Str)
- PythonVersion = "0"
- For i=0 To objMatches.Count-1 ' должно быть только одно совпадение
- PythonVersion = objMatches.Item(i).Value
- Next
- GetPythonVersion = PythonVersion
- Else
- Err.Clear
- End If
- End Function
- Function DownloadPython()
- Err.Clear
- Set x = CreateObject("WinHttp.WinHttpRequest.5.1")
- call x.Open("GET", "https://www.python.org/ftp/python/3.5.3/python-3.5.3-amd64-webinstall.exe", 0)
- x.Send()
- Set s = CreateObject("ADODB.Stream")
- s.Mode = 3
- s.Type = 1
- s.Open()
- s.Write(x.responseBody)
- call s.SaveToFile("python-3.5.3-amd64-webinstall.exe", 2)
- DownloadPython = "python-3.5.3-amd64-webinstall.exe"
- End Function
- Function InstallPython()
- InstallPython = False
- PythonVersion = GetPythonVersion()
- If Mid(PythonVersion, 1, 3)="3.5" Then
- InstallPython = True
- Else
- txt = vbNullString
- If Len(PythonVersion) > 0 Then
- txt = "Обнаружена не подходящая версия питона"
- Else
- txt = "Питон не установлен"
- End If
- If MsgBox(txt & vbCrLf & "Скачать подходящую версию?", 4) = 6 Then
- MsgBox("Не забудьте поставить галочку в пункте 'Add Python 3.5 to PATH'")
- Set WshShell = WScript.CreateObject("WScript.Shell")
- WshShell.Run DownloadPython(), 0, True
- MsgBox("установка питона завершена, запустите скрипт повторно для продолжения установки")
- End If
- End If
- End Function
- If InstallPython() Then
- Set WshShell = WScript.CreateObject("WScript.Shell")
- 'установка tensorflow
- WshShell.Run "pip install --upgrade pip", 1, True
- WshShell.Run "pip install --ignore-installed --upgrade https://ci.tensorflow.org/view/Nightly/job/nightly-win/DEVICE=cpu,OS=windows/lastSuccessfulBuild/artifact/cmake_build/tf_python/dist/tensorflow-1.0.1-cp35-cp35m-win_amd64.whl", 1, True
- WshShell.Run "pip install -U pip setuptools", 1, True
- WshShell.Run "pip install matplotlib" , 1, True
- WshShell.Run "pip install jupyter" , 1, True
- If MsgBox("Всё готово, запустить Jupyter notebook?", 4) = 6 Then
- WshShell.Run "jupyter notebook" , 1, False
- End If
- End If
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement