我正在使用Python3.6,需要在命令行中运行代码。当我在PyCharm中运行代码时,代码可以工作,但当我使用命令行时,会出现以下错误:
File "path", line 43, in <module>
rb = ds.GetRasterBand(1)
AttributeError: 'NoneType' object has no attribute 'GetRasterBand'
我好像对这些台词有点意见:
ds = gdal.Open('tif_file.tif', gdal.GA_ReadOnly)
rb = ds.GetRasterBand(1)
img_array = rb.ReadAsArray()
有人知道我可能做错了什么吗?你知道吗
编辑
一些魔法发生了。今天早上我试着运行我的代码,一切都很好。我想我的电脑需要的是重启什么的。谢谢大家的帮助。你知道吗
from the gdal documentation:
看起来您试图打开的文件不是有效的gdal文件,或者文件选择中正在进行其他操作。您可以尝试将程序定向到一个已知良好的在线文件来测试它。你知道吗
相关问题 更多 >
编程相关推荐