如何在 Python 中使用命令行 运行 可执行文件?

How to run a executable with command line in Python?

我已经用 pip 安装了这个包:https://github.com/retostauffer/PyGFSV2。该软件包附带两个可执行文件(GFSV2_get 和 GFSV2_bulk)。但是,我不知道如何在 Python 中打开可执行文件。

因此,安装后,包作者建议通过调用尝试安装:

GFSV2_get --step 12 24 --level 700 850 --param tmp_pres --date 2005-01-01

所以,我在 Anaconda Prompt 中输入了下一个:

(base) C:\Users\vrida>CD C:\Users\vrida\anaconda3\Scripts

(base) C:\Users\vrida\anaconda3\Scripts>python GFSV2_get --step 12 24 --level 700 850 --param tmp_pres --date 2005-01-01

但是,它没有用。出现这个:

# DEBUG Loading default config file from package source.
# INFO Config file read, return.
# INFO Processing date 2005-01-01 00Z
# INFO Downloading inventory information data
# DEBUG Reading ftp://ftp.cdc.noaa.gov/Projects/Reforecast2/2005/200501/2005010100/mean/latlon\tmp_pres_2005010100_mean.grib2.inv
# ERROR Problems reading file, reason: "ftp error: URLError("ftp error: error_perm('550 Failed to change directory.')")".
# ERROR Could not download inventory file! Skip this.
# INFO Inventory empty, skip this file
# INFO Downloading inventory information data
# DEBUG Reading ftp://ftp.cdc.noaa.gov/Projects/Reforecast2/2005/200501/2005010100/sprd/latlon\tmp_pres_2005010100_sprd.grib2.inv
# ERROR Problems reading file, reason: "ftp error: URLError("ftp error: error_perm('550 Failed to change directory.')")".
# ERROR Could not download inventory file! Skip this.
# INFO Inventory empty, skip this file

我是 Python 的初学者。所以我有两个问题:

1 - 如何 运行 这些可执行文件,例如使用 Anaconda Prompt?

2 - 任何人都可以在尝试安装后下载软件包,如果成功,请告诉我如何进行安装?

我认为你应该联系包的维护者。显然,图书馆试图通过 ftp 下载一些文件,使用系统文件分隔符,在你的例子中是 \(因为你使用的是 windows),而不是 /: ftp://ftp.cdc.noaa.gov/Projects/Reforecast2/2005/200501/2005010100/mean/latlon\tmp_pres_2005010100_mean.grib2.inv

可以使用标准 ftp 客户端通过匿名 ftp 访问访问该文件。所以这应该是 python 库的问题。