为 python 库运行 .bat 文件

问题描述 投票:0回答:0

我有 Windows 操作系统(操作系统),我正在尝试安装 libpostal 库https://github.com/openvenues/libpostal

我想使用 .bat 脚本处理一切(安装),然后尝试运行示例。

这是一个 .bat 脚本,我发现它测试安装是否已经完成,否则会继续直到完成(我想我之前可能已经完成了其中的一些部分):

  @echo off

:: Check if MSYS2 and MinGW are installed
where msys2 2>nul >nul
if %errorlevel% equ 0 (
    echo MSYS2 is already installed. Use --force to reinstall.
) else (
    :: Install MSYS2 and MinGW
    choco install msys2
    refreshenv
)

:: Check if MSYS2 packages are updated
pacman -Qu 2>nul >nul
if %errorlevel% equ 0 (
    echo MSYS2 packages are already updated. Use --force to reinstall.
) else (
    :: Update MSYS2 packages
    pacman -Syu
)

:: Check if build dependencies are installed
pacman -Q autoconf automake curl git make libtool gcc mingw-w64-x86_64-gcc 2>nul >nul
if %errorlevel% equ 0 (
    echo Build dependencies are already installed. Use --force to reinstall.
) else (
    :: Install build dependencies
    pacman -S autoconf automake curl git make libtool gcc mingw-w64-x86_64-gcc
)

:: Check if libpostal is cloned
if exist libpostal (
    echo libpostal repository is already cloned. Use --force to reinstall.
) else (
    :: Clone libpostal repository
    git clone https://github.com/openvenues/libpostal
)

cd libpostal

:: Check if libpostal is built and installed
if exist C:/Program Files/libpostal/bin/libpostal.dll (
    echo libpostal is already built and installed. Use --force to reinstall.
) else (
    :: Build and install libpostal
    cp -rf windows/* ./
    ./bootstrap.sh
    ./configure --datadir=C:/libpostal
    make -j4
    make install
)

:: Check if libpostal is added to PATH environment variable
setx /m PATH "%PATH%;C:\Program Files\libpostal\bin" 2>nul >nul
if %errorlevel% equ 0 (
    echo libpostal is already added to PATH environment variable. Use --force to reinstall.
) else (
    :: Add libpostal to PATH environment variable
    setx PATH "%PATH%;C:\Program Files\libpostal\bin"
)

:: Test libpostal installation
libpostal "100 S Broad St, Philadelphia, PA"

pause

我将此代码保存在记事本文件中,名为“bat_script.bat”,然后我左键单击 .bat 图标,以管理员身份运行....但命令提示符/shell 窗口总是在我阅读发生了什么之前关闭。我试着截图了:

有人可以帮忙吗?

python shell batch-file
© www.soinside.com 2019 - 2024. All rights reserved.