path manipulation怎么解决_PyCharm报错与解决方法一览
報錯:
IndentationError:expected an indented block
分析:
縮進(jìn)錯誤!
解決:
你只要在出現(xiàn)錯誤的那一行,按空格或Tab(但不能混用)鍵縮進(jìn)就行。往往有的人會疑問:我根本就沒縮進(jìn)怎么還是錯,不對,該縮進(jìn)的地方就要縮進(jìn),不縮進(jìn)反而會出錯
報錯:
AttributeError: 'NoneType' object has no attribute 'shape'
分析:
多發(fā)生在圖像處理問題
解決:
經(jīng)過檢查發(fā)現(xiàn)是python中圖像不存在
報錯:
error: (-215:Assertion failed) !ssize.empty() in function 'cv::resize'
分析:
在該路徑下沒有圖像,或者說該路徑不存在。也就是說,cv讀到的是0byte數(shù)據(jù)
解決:
① 看是不是沒有路徑
② 看是不是該路徑下的圖片不存在
③ 即使圖片存在,但是為0byte也是錯誤的
報錯:FileNotFoundError: [Errno 2] No such file or directory: 'data/coco.names'
分析:
這一般都是當(dāng)前工程文件的文件夾中,后面標(biāo)注的這個文件夾里沒有文件
解決:
添加文件即可
報錯:
AssertionError: Cannot capture source
分析:
解決:
報錯:
SyntaxError: invalid syntax
分析:
英文是“非法語句”的意思。漏標(biāo)點(diǎn)符號(例如漏分號,漏&號),多標(biāo)點(diǎn)符號,拼寫錯,等等都會造成這種錯
解決:
檢查拼寫錯誤
報錯:
RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 0
分析
使用DataLoader加載圖像,這些圖像中的一些具有3個通道(彩色圖像),而其他圖像可能具有單個通道(BW圖像),由于dim1的尺寸不同,因此無法將它們連接成批次。嘗試將img = img.convert(‘RGB’)添加到數(shù)據(jù)集中的__getitem__中
解決
dataloader
def __getitem__(self,index):img_path=self.imgs[index]label=self.labels[index]data=Image.open(img_path) # data = data.convert('RGB')data=self.transform(data)return data,label報錯:
AssertionError: Cannot capture source
分析:
解決:
報錯:
AssertionError: Cannot capture source
分析:
解決:
報錯:
AssertionError: Cannot capture source
分析:
解決:
總結(jié)
以上是生活随笔為你收集整理的path manipulation怎么解决_PyCharm报错与解决方法一览的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python爬虫自学路线_python
- 下一篇: python中执行sql语句_Pytho