我具有用于在Windows Machine上显示图像的枕头功能。它可以在测试数据集中使用。
药丸功能:
from PIL import Image
def get_thumbnail(path):
i = Image.open(path)
print(path)
i.show()
return i
我将该功能用于新的创建新的熊猫列,该列应该保存pil图像信息。图像是基于图像URL生成的,该图像URL存储在另一个熊猫列中:
adInfoListPD['Ad_thumb']
看起来像这样:
> 0
> C:UsersuserDocuments 01MLwillatGames_Konsolen 3_ps4-pro-500-million-limited-edition-blau-transparent-bundle-29598325900_ps4-pro-500-million-limited-edition-blau-transparent-bundle-295983259__thumb_100x75.jpg
> 1
> C:UsersuserDocuments 01MLwillatGames_Konsolen 4_playstation-4-20th-anniversary-edition-ungeoeffnet-29586533000_playstation-4-20th-anniversary-edition-ungeoeffnet-295865330__thumb_100x75.jpg
> 2
> C:UsersuserDocuments 01MLwillatGames_Konsolen 5_playstation-4-20th-anniversary-sammleredition-ovp-29496806400_playstation-4-20th-anniversary-sammleredition-ovp-294968064__thumb_100x75.jpg
> 3
> C:UsersuserDocuments 01MLwillatGames_Konsolen 7_gratis-versand-alles-zusammen-xxxl-paket-29517022700_gratis-versand-alles-zusammen-xxxl-paket-295170227__thumb_100x75.jpg
> 4
> C:UsersuserDocuments 01MLwillatGames_Konsolen 8_groesste-ankauf-mit-sofortigem-bargeld-30099513000_groesste-ankauf-mit-sofortigem-bargeld-300995130__thumb_100x75.jpg
> 5
> C:UsersuserDocuments 01MLwillatGames_Konsolen 9_wir-zahlen-sofort-bargeld-30099285800_wir-zahlen-sofort-bargeld-300992858__thumb_100x75.jpg
,我正在使用此行创建可以保存药丸图像的列: adInfoListPD['image'] = adInfoListPD.Ad_thumb.map(lambda f: get_thumbnail(f))
。
我有错误:
FileNotFoundError: [Errno 2] No such file or directory:
'C:\Users\user\Documents\001ML\willat\Games_Konsolen\03_ps4-pro-500-million-limited-edition-blau-transparent-bundle-29598325900_ps4-pro-500-million-limited-edition-blau-transparent-bundle-295983259__thumb_100x75.jpg'
我已经两次检查路径,没关系。我还阅读了有关Windows上有关Python路径问题的所有其他帖子。我认为我以正确的方式通过了道路。正如我所说,在演示数据上一切都可以,但是它与我的数据无效。
路径是最后的问题。
我使用了:
os.path.join(dir_base,category_folder,dir_name,file_name_thumb)
创建可以在所有平台上工作的正确路径。
我已经在使用它,但我不知道os.path.join
也可以与文件名一起使用。因此,我正在手动添加它,因此省略了"\"
dir_name
和file_name_thumb
。
,我还将"\\?\"
添加到PIL功能中的路径:
def get_thumbnail(path):
path = "\\?\"+path
i = Image.open(path)
return i
用窗户上的路径超过255的路径解决问题。同时,这并不应该弄乱Linux机器上的路径解释。但是我不确定...