问题
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