V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
noparking188
V2EX  ›  Python

Poetry 安装包太慢的问题

  •  
  •   noparking188 · 2019-06-18 22:33:50 +08:00 · 6718 次点击
    这是一个创建于 1764 天前的主题,其中的信息可能已经有所发展或是发生改变。

    virtualenv -> Pipenv -> Poetry

    逐渐接触到 Poetry 这个 Python 的包管理工具,感觉很不错,但是,太慢了吧,今天在公司装几个包好几分钟还没好,就 Ctrl+C,用 virtualenv 了

    Poetry resolving dependencies is amazingly slow

    Why is the dependency resolution process slow?

    pip 源为中科大,wsl 里使用

    有小伙伴能够指教一下嘛,公司的网速很快的啊,没毛病

    22 条回复    2020-07-30 12:27:07 +08:00
    onlyice
        1
    onlyice  
       2019-06-18 23:35:07 +08:00 via Android
    --verbose 看看呀。
    janxin
        2
    janxin  
       2019-06-19 00:05:57 +08:00
    =,=其实 WSL 就很慢
    gjquoiai
        3
    gjquoiai  
       2019-06-19 00:31:48 +08:00
    poetry 似乎不会使用 pip 配置的源,你需要在 pyproject.toml 里定义
    Trim21
        4
    Trim21  
       2019-06-19 01:02:17 +08:00
    @gjquoiai #3 不太确定 wsl 里面是怎么处理的,但 poetry 在 windows 下面实际上是通过命令调用的 pip,所以会使用 pip 配置的源


    [EnvCommandError]
    Command ['python', '-m', 'pip', 'install', '--no-deps', 'virtualenv==16.6.1'] errored with the following output:
    Looking in indexes: https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
    Collecting virtualenv==16.6.1
    Could not find a version that satisfies the requirement virtualenv==16.6.1 (fr
    om versions: 0.8, 0.8.1 ……, 16.4.4.dev0, 16.5.0, 16.6.0)
    No matching distribution found for virtualenv==16.6.1
    ericgui
        5
    ericgui  
       2019-06-19 02:10:14 +08:00
    Poetry 也是全局安装 ? 类似 pip
    noparking188
        6
    noparking188  
    OP
       2019-06-19 08:01:27 +08:00
    @ericgui 不知道您讲的全局是啥意思,Poetry 还是和 virtualenv 一样使用一个 venv 目录,你可以设置指定其存储在项目根目录下
    noparking188
        7
    noparking188  
    OP
       2019-06-19 08:03:28 +08:00
    @gjquoiai poetry 默认就是使用的 pip 源,而 pipenv 不是,需要在 Pipfile 中修改
    noparking188
        8
    noparking188  
    OP
       2019-06-19 08:04:48 +08:00
    @janxin 不应该吧,pip 安装是满速
    ericgui
        9
    ericgui  
       2019-06-19 08:07:24 +08:00
    @noparking188 嗯,那就好,这就是我所说的局部安装,谢谢
    janxin
        10
    janxin  
       2019-06-19 09:25:02 +08:00
    @noparking188 我是说 WSL 的 io 很慢
    frostming
        11
    frostming  
       2019-06-19 09:35:32 +08:00
    没有人注意到中科大的 pypi 源没有了吗?
    noparking188
        12
    noparking188  
    OP
       2019-06-19 09:48:42 +08:00
    @janxin 哭,IO 再慢也要比带宽快吧
    noparking188
        13
    noparking188  
    OP
       2019-06-19 09:49:01 +08:00
    @frostming 注意到重定向到清华
    janxin
        14
    janxin  
       2019-06-19 09:55:06 +08:00
    @noparking188 上一次 apt upgrade,下载 5 分钟,安装的时间我去打了一回合文明
    gjquoiai
        15
    gjquoiai  
       2019-06-20 01:04:08 +08:00
    @noparking188 #7
    @Trim21 #4

    下面是我的推测哈,不确定是不是这么实现的:
    poetry 在确定了要下载的包的时候会用 pip 的 config,但 poetry 慢不是慢在下包,而是处理依赖关系。处理依赖关系的时候如果不设置会直接从 pypi.org 获取包信息,从 log 里大概能看出来:




    如果在 pyproject.toml 里设置了

    [[tool.poetry.source]]
    name = "ali"
    url = "https://mirrors.aliyun.com/pypi/simple/"

    就会从指定的地方获取依赖关系了:



    不过由于 pypi mirror 的固有问题,用其它源偶尔会报错,一般重试一下就好了。。_(:з)∠)_
    Trim21
        16
    Trim21  
       2019-06-20 01:35:17 +08:00
    @gjquoiai #15 感谢
    不过这样的话,就没法在 ci 和本地用两个源了…
    noparking188
        17
    noparking188  
    OP
       2019-06-20 09:48:16 +08:00
    @gjquoiai 感觉是这样。作者也说了,poetry 在解析上花了更多的时间,,这样可以那啥的用精确的版本号的包,尽可能避免依赖冲突,听起来很有道理
    我试试在 pyproject.toml 改源看看速度
    noparking188
        18
    noparking188  
    OP
       2019-06-20 09:50:57 +08:00
    @Trim21 可以提个 issue,建议作者加个命令行选项可以设置全局使用指定源,或者有时间的话自己提个 pr
    shell 这个 feature 就是有人建议作者借鉴下 Pipenv,然后合并了 pr
    wzw
        19
    wzw  
       2020-02-04 17:59:39 +08:00
    要是 pycharm 也支持就最好了, 会方便很多
    shunconf
        20
    shunconf  
       2020-04-04 05:25:09 +08:00
    我刚试用了一下,我还是用回 pipenv 吧
    hp66722667
        21
    hp66722667  
       2020-05-21 10:52:56 +08:00
    @wzw 支持的,你在 pycharm 中找到把 poetry 对应的解析器位置就可以啊
    abersheeran
        22
    abersheeran  
       2020-07-30 12:27:07 +08:00
    速度太慢 https://aber.sh/articles/python-poetry/#pypi 可以参考这个。Poetry 我用起来比 pipenv 好使。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1644 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 16:52 · PVG 00:52 · LAX 09:52 · JFK 12:52
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.