推荐学习书目
› 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
caneman
V2EX  ›  Python

pip 安装包的时候如何控制搜索顺序?

  •  
  •   caneman · Feb 25, 2022 · 3601 views
    This topic created in 1677 days ago, the information mentioned may be changed or developed.

    RT ,搭了个私有源地址,当私有源和共有源有同名包的时候,默认会从公有源下载,如何解决这个问题?

    全机只有一个 pip.ini ( windows ), 位于 C:\Users\Administrator\AppData\Roaming\pip

    内容如下

    [global]
    timeout = 10
    index-url =  http://121.xxx.xxx.xxx:8080/simple/
    extra-index-url = http://pypi.douban.com/simple/
    [install]
    trusted-host =
        121.xxx.xxx.xxx
        pypi.douban.com
    

    想一劳永逸的方式解决, 不想每次安装的时候加 -i 来实现

    删除 douban 源,只保留私有源的情况下,安装是成功的,但是有多个源地址的时候,每次总是从 douban 源里面装同名包,明明已经把它优先级排低了...

    虚拟 conda 环境(但是确定全机只有一个 pip.ini ,不存在多个 pip.ini 不同调用优先级的问题)

    4 replies  •  2022-02-28 19:45:46 +08:00
    lisongeee
        1
    lisongeee  
       Feb 25, 2022
    可以尝试一下 poetry 这类包管理工具,在 pyproject.toml 里可以配置
    ClericPy
        2
    ClericPy  
       Feb 25, 2022
    之前拜托同事也折腾私有 pipy 到 maven 上, 后来嫌麻烦, 直接走内网 git: 的方式安装了...

    是 linux 的话 alias 先凑合用用? 很早以前我好像也有这问题, 各种清理 cache 然后 -vvvv 也没啥办法. 刚才搜 pip search private priority 也没发现什么好的建议
    qq296015668
        3
    qq296015668  
       Feb 27, 2022
    应该还有一个 ~/.pydistutils.cfg

    cat ~/.pydistutils.cfg

    ## Note, this file is written by cloud-init on first boot of an instance
    ## modifications made here will not survive a re-bundle.
    ###
    [global]
    index-url=http://mirrors.cloud.aliyuncs.com/pypi/simple/

    [install]
    trusted-host=mirrors.cloud.aliyuncs.com
    frostming
        4
    frostming  
       Feb 28, 2022
    你要不要试试 extra index 和 index 换一下?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1421 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 16:36 · PVG 00:36 · LAX 09:36 · JFK 12:36
    ♥ Do have faith in what you're doing.