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
caneman
V2EX  ›  Python

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

  •  
  •   caneman · 2022-02-25 18:05:53 +08:00 · 2573 次点击
    这是一个创建于 791 天前的主题,其中的信息可能已经有所发展或是发生改变。

    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 条回复    2022-02-28 19:45:46 +08:00
    lisongeee
        1
    lisongeee  
       2022-02-25 20:34:48 +08:00
    可以尝试一下 poetry 这类包管理工具,在 pyproject.toml 里可以配置
    ClericPy
        2
    ClericPy  
       2022-02-25 21:52:33 +08:00
    之前拜托同事也折腾私有 pipy 到 maven 上, 后来嫌麻烦, 直接走内网 git: 的方式安装了...

    是 linux 的话 alias 先凑合用用? 很早以前我好像也有这问题, 各种清理 cache 然后 -vvvv 也没啥办法. 刚才搜 pip search private priority 也没发现什么好的建议
    qq296015668
        3
    qq296015668  
       2022-02-27 10:24:23 +08:00
    应该还有一个 ~/.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  
       2022-02-28 19:45:46 +08:00
    你要不要试试 extra index 和 index 换一下?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2907 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 03:06 · PVG 11:06 · LAX 20:06 · JFK 23:06
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.