【问题标题】:upgrade pillow suggested, but then already up-to-date建议升级枕头,但已经是最新的
【发布时间】:2019-12-15 11:19:23
【问题描述】:

我正在尝试修复对 Image 模块的调用(直到现在我才知道这个 Python 图像库),我需要升级 Pillow,因为 /usr/lib/python3/dist-packages/PIL/Image.py 中的文件声明版本为 1.1.7 ,但有更新的版本可用。

$  sudo pip3 install Pillow
[sudo] password di user: 
The directory '/home/user/.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.
The directory '/home/user/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already satisfied (use --upgrade to upgrade): Pillow in /usr/lib/python3/dist-packages
You are using pip version 8.1.1, however version 19.2.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

You are using pip version 8.1.1, however version 19.2.1 is available.

但是,当我尝试升级时:

user:~/Downloads$ pip3 install --upgrade pip
Requirement already up-to-date: pip in /home/user/.local/lib/python3.7/site-packages (19.2.1)

我很困惑,我错过了什么?

【问题讨论】:

    标签: pip python-imaging-library python-3.7


    【解决方案1】:

    第一条消息告诉你有一个可用于 pip 的升级,而不是 Pillow。

    第一个命令使用sudo。第二个没有。 sudo 路径中的 pip 必须与用户路径中的不同。

    不建议将sudo 与 pip 一起使用。请改用--user 开关。

    另外,Image.py 中的 1.1.7 版本是 PIL 的版本,其中 Pillow 是一个 fork。 Pillow 本身有另一个版本号,正在从 Pillow 中删除 1.1.7 版本。

    所以不要使用sudo pip3 ...,而是:

    pip3 install --user --upgrade pip
    pip3 install --user --upgrade pillow
    

    【讨论】:

    • 谢谢!在我按照您建议的方式升级后它可以工作。你能不能说一下让 sudo 和用户路径中的 pip 相同的方法?
    【解决方案2】:

    试试

    sudo -H pip3 install Pillow 
    

    另外,如果您要以sudo 执行此操作,则需要修复权限

    $ sudo chown -R USERNAME /Users/USERNAME/Library/Logs/pip
    $ sudo chown -R USERNAME /Users/USERNAME/Library/Caches/pip
    

    注意:不建议以超级用户身份执行任何这些操作。

    按照文档了解最佳实践:https://pip.pypa.io/en/stable/reference/pip_install/

    以后升级包:

    pip list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1  | xargs -n1 pip install -U
    

    对于旧版本:

    pip freeze --local | grep -v '^\-e' | cut -d = -f 1  | xargs -n1 pip install -U
    

    简化:

    v2

    $ pip install pip-review
    $ pip-review --local --interactive
    

    v3

    $ pip3 install pip-review
    $ py -3 -m pip_review --local --interactive
    

    另一种解决方案:https://github.com/achillesrasquinha/pipupgrade

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-08
      • 2014-07-13
      • 1970-01-01
      • 2013-01-08
      • 2020-10-30
      相关资源
      最近更新 更多