Chocolatey - `Msys2` 库已安装

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

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

我注意到正确安装 libpostal 需要很多步骤。我想使用 .bat 脚本处理所有安装步骤,然后尝试运行示例地址。

我已经在这里发布问题为 python 库运行 .bat 文件,现在我尝试使用建议来改进脚本:

@echo off

REM 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 (
    REM Install MSYS2 and MinGW
    choco install msys2
    refreshenv
)

REM 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 (
    REM Update MSYS2 packages
    pacman -Syu
)
    
REM 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 (
    REM Install build dependencies
    pacman -S autoconf automake curl git make libtool gcc mingw-w64-x86_64-gcc
)

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

cd libpostal

REM 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 (
    REM Build and install libpostal
    cp -rf windows/* ./
    ./bootstrap.sh
    ./configure --datadir=C:/libpostal
    make -j4
    make install
)
    
REM 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 (
    REM Add libpostal to PATH environment variable
    setx PATH "%PATH%;C:\Program Files\libpostal\bin"
)

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

pause

这是日志:

我认为可能存在问题,因为我过去已经尝试安装其中一些程序(例如 MSYS2)...这就是为什么我尝试编写代码以跳过安装和更新(如果已经存在)的原因。

我卡住了——怎么办?

python windows batch-file
1个回答
0
投票

两个建议

以管理员身份运行CMD

为此,单击开始按钮,键入 CMD,等待它出现在列表中,然后右键单击它,以便您可以选择“以管理员身份运行”。

从那里,你应该能够在没有收到第一条警告消息的情况下运行 chocolatey。

upgrade
代替
install

这将避免有关已安装的警告。

改变

    choco install msys2

    choco upgrade msys2
© www.soinside.com 2019 - 2024. All rights reserved.