qpython android IOError:[Erno 2]没有这样的文件或目录 [英] qpython android IOError: [Erno 2] No such file or directory

查看:87
本文介绍了qpython android IOError:[Erno 2]没有这样的文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从qpython中的简单python脚本调用图像,但收到错误消息:

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')
        }

如果不带'r'参数,它将引发相同的错误.还尝试过双前驱&反斜线...

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

推荐答案

似乎您尚未设置图像的完整路径,因此它会错过绝对路径开头的斜杠.

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

尝试/storage/emulated .....而不是storage/emulated ....

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

这篇关于qpython android IOError:[Erno 2]没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆