qpython android IOError: [Erno 2] No such file or directory

守給你的承諾、 提交于 2020-01-24 15:37:49

问题


I am trying to call an image from a simple python script in qpython but get the error message:

qpython android IOError: [Erno 2] No such file or directory

I am wondering if I am using the correct directory convention? here is the code:

import numpy as np
from PIL import Image 

spinner = {
        1: Image.open('storage/emulated/0/qpython/scripts/shapes/norm.jpg','r'),
        2: Image.open('storage/emulated/0/qpython/scripts/shapes/square.jpg','r'),
        3: Image.open('storage/emulated/0/qpython/scripts/shapes/fly.jpg','r'),
        4: Image.open('storage/emulated/0/qpython/scripts/shapes/tri.jpg','r'),
        5: Image.open('storage/emulated/0/qpython/scripts/shapes/special.jpg','r'),
        6: Image.open('storage/emulated/0/qpython/scripts/shapes/rect.jpg','r'),
        7: Image.open('storage/emulated/0/qpython/scripts/shapes/salad.jpg','r'),
        8: Image.open('storage/emulated/0/qpython/scripts/shapes/circle.jpg','r'),
        9: Image.open('storage/emulated/0/qpython/scripts/shapes/banana.jpg','r')
        }

It throws the same error without the 'r' argument. Also tried double fwd & back slashes...


回答1:


it seems that you have not set the full path to your images it misses the slash at the beginning of the absolute path.

Try /storage/emulated..... Instead of storage/emulated ....



来源:https://stackoverflow.com/questions/46957757/qpython-android-ioerror-erno-2-no-such-file-or-directory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!