【发布时间】:2021-04-17 23:52:51
【问题描述】:
在 appveyor 中安装了所有必需的库后,当测试开始时它会失败,因为它无法导入已安装的库之一。
错误
python test.py
Traceback (most recent call last):
File "C:\projects\hapi\Examples\test.py", line 7, in <module>
import Hapi
File "C:\Miniconda-x64\envs\Hapi-env\lib\site-packages\hapi_nile-1.0.4-py3.9.egg\Hapi\__init__.py", line 31, in <module>
import Hapi.distparameters
File "C:\Miniconda-x64\envs\Hapi-env\lib\site-packages\hapi_nile-1.0.4-py3.9.egg\Hapi\distparameters.py", line 14, in <module>
import gdal
ModuleNotFoundError: No module named 'gdal'
Command exited with code 1
之前我通过使用 while 循环从 requitement.txt 安装要求解决了这个问题,但由于某种原因,它现在无法正常工作,并且我收到系统无法识别 while 的错误
while read requirement; do conda install --yes $requirement; done < requirement.txt
'while' is not recognized as an internal or external command,
operable program or batch file.
Command exited with code 1
现在当我使用安装需求时
- cmd: conda install --yes --file requirement.txt
它无法从require.txt文件中导入已经安装的库
这是我的 appveyor.yml 文件
install:
- cmd: SET PATH=%CONDA_INSTALL_LOCN%;%CONDA_INSTALL_LOCN%\Scripts;%PATH%
- cmd: SET PATH=%MINICONDA%;%MINICONDA%\\Scripts;%PATH%
- cmd: conda config --set always_yes yes --set changeps1 no
- cmd: conda update -q conda
- cmd: conda info -a
# Create a new environment
- cmd: conda create -q -n Hapi-env python=%PYTHON_VERSION% --yes
- cmd: activate Hapi-env
- cmd: conda clean --tarballs -y
- cmd: conda clean --packages -y
# Install various dependencies
- cmd: conda config --add channels conda-forge
- cmd: conda install --yes --file requirement.txt
- cmd: python -V
- cmd: python setup.py build_ext --inplace
- cmd: python setup.py install
test_script:
- cmd: cd Examples/
- cmd: python test.py
我的 requirements.txt 文件是
pip
numpy
gdal
affine
fiona
proj
pyproj
pandas
geopandas
matplotlib
python
scipy
shapely
statsmodels
rasterio
rasterstats
oasis
netCDF4
scikit-learn
scikit-image
ecmwf-api-client
joblib
更新: 我发现迭代require.txt文件中的库的while循环之前没有工作,但是,构建并没有崩溃并继续构建,而是因为构建成功时没有测试。 所以while循环在appveyor中不起作用
【问题讨论】: