相关疑难解决方法(0)

如何从Python中读取URL中的图像数据?

当我们处理本地文件时,我正在尝试做的事情相当简单,但是当我尝试使用远程URL执行此操作时会出现问题.

基本上,我正在尝试从URL中提取的文件中创建PIL图像对象.当然,我总是可以获取URL并将其存储在临时文件中,然后将其打开到图像对象中,但这样效率非常低.

这就是我所拥有的:

Image.open(urlopen(url))
Run Code Online (Sandbox Code Playgroud)

它散开了抱怨,这seek()是不可用的,所以我试过这个:

Image.open(urlopen(url).read())
Run Code Online (Sandbox Code Playgroud)

但这也不起作用.有没有更好的方法来做到这一点,或者写一个临时文件是可接受的做这种事情的方式?

python python-imaging-library

159
推荐指数
9
解决办法
19万
查看次数

无法安装PIL

我无法安装PIL.当我跑步时,pip install PIL我得到:

Downloading/unpacking PIL
  Could not find any downloads that satisfy the requirement PIL
Cleaning up...
No distributions at all found for PIL
Storing debug log for failure in /tmp/tmpWJojCu
Run Code Online (Sandbox Code Playgroud)

我试过按照这个问题的答案,但我得到了同样的错误.

Stack:Python 2.7,PIP,EC2 Ubuntu机器.

python python-imaging-library

2
推荐指数
1
解决办法
6686
查看次数

标签 统计

python ×2

python-imaging-library ×2