UnsupportedOperation:fileno-如何修复此Python依赖混乱? [英] UnsupportedOperation: fileno - How to fix this Python dependency mess?

查看:647
本文介绍了UnsupportedOperation:fileno-如何修复此Python依赖混乱?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建相当广泛的Python后端,并且在服务器A上一切正常.然后,我将系统安装在新的(开发)服务器B上,在该服务器上,我只是从头开始再次安装了所有pip软件包.看起来一切正常,所以我做了pip freeze.然后,我获取了该列表并在服务器A上升级了软件包.

I'm building quite an extensive Python backend and things were working quite good on server A. I then installed the system on a new (development) server B on which I simply installed all pip packages again from scratch. Things seemed to work fine, so I did a pip freeze. I then took that list and upgraded the packages on server A.

但是,正如您可能期望的那样,我应该对此有所了解.我没有在机器B上测试足够的东西,所以我遇到了3.0.0版枕头的问题.所以我降级到1.7.8版本.那解决了一个问题,错误给了我另一个问题:

But, as you might expect I should have known better. I didn't test things on machine B wel enough, so I ran into a problem with Pillow version 3.0.0. So I downgraded to version 1.7.8. That solves that single problem, bug gives me another one:

File "/home/kramer65/theproject/app/models/FilterResult.py", line 26, in to_json
    self.image.save(b, 'JPEG')
  File "/usr/local/lib/python2.7/dist-packages/PIL/Image.py", line 1437, in save
    save_handler(self, fp, filename)
  File "/usr/local/lib/python2.7/dist-packages/PIL/JpegImagePlugin.py", line 471, in _save
    ImageFile._save(im, fp, [("jpeg", (0,0)+im.size, 0, rawmode)])
  File "/usr/local/lib/python2.7/dist-packages/PIL/ImageFile.py", line 476, in _save
    fh = fp.fileno()
UnsupportedOperation: fileno

在这里我有点迷路了.据我所知,这是Pillow本身的问题,所以我不知道为什么它曾经起作用,为什么它不再起作用.

And here I'm kinda lost. As far as I know this is a problem in Pillow itself, so I wouldn't know why it used to work and why it doesn't work anymore.

我在互联网上进行搜索,但是找不到任何解决方案.

I searched around on the internet, but I couldn't find any solution.

有人知道我能做些什么来解决这个问题吗?

Does anybody know what I could do to solve this?

ps.没有安装PIL,所以PIL和Pillow之间不是冲突

ps. PIL is not installed, so it's not a collision between PIL and Pillow

我刚刚在Python中测试了import Image(这表明仍在安装PIL).令我惊讶的是,即使pip告诉我它尚未安装,该操作也成功完成了:

I just tested an import Image in Python (which would suggest that PIL is still installed). To my surprise that succeeds, even though pip tells me that it is not installed:

$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import Image
>>> exit()
$ sudo pip uninstall PIL
The directory '/home/hielke/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Cannot uninstall requirement PIL, not installed

推荐答案

我终于设法解决了问题.我将枕头从3.0.0降级到1.7.8的原因是,在

I finally managed to fix things. The reason I downgraded pillow from 3.0.0 to 1.7.8, is because those where the only two versions I saw listed on the Pillow Pypi package index. I finally remembered that I had one more server on which I once tested this code and there it was still working. A quick pip freeze told me that it had Pillow version 2.3.0 installed. So after installing that on my dev server things worked beautifully again.

那么我从中学到了什么?使用pip freeze

So what have I learned from this? Use pip freeze!

这篇关于UnsupportedOperation:fileno-如何修复此Python依赖混乱?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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