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

关于 Debian12 无法使用 pip install 安装 cos- Python -sdk-v5 的问题

  •  
  •   joeyv2 ·
    zystzyt · 159 天前 · 1677 次点击
    这是一个创建于 159 天前的主题,其中的信息可能已经有所发展或是发生改变。

    使用官方命令:pip install -U cos-python-sdk-v5

    error: externally-managed-environment
    
    × This environment is externally managed
    ╰─> To install Python packages system-wide, try apt install
        python3-xyz, where xyz is the package you are trying to
        install.
    
        If you wish to install a non-Debian-packaged Python package,
        create a virtual environment using python3 -m venv path/to/venv.
        Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
        sure you have python3-full installed.
    
        If you wish to install a non-Debian packaged Python application,
        it may be easiest to use pipx install xyz, which will manage a
        virtual environment for you. Make sure you have pipx installed.
    
        See /usr/share/doc/python3.11/README.venv for more information.
    
    note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
    hint: See PEP 668 for the detailed specification.
    

    使用:pipx install cos-python-sdk-v5

    Note: Dependent package 'charset-normalizer' contains 1 apps
      - normalizer
    
    No apps associated with package cos-python-sdk-v5. Try again with '--include-deps'
    to include apps of dependent packages, which are listed above. If you are attempting
    to install a library, pipx should not be used. Consider using pip or a similar tool
    instead."
    
    9 条回复    2024-01-16 22:19:54 +08:00
    Masoud2023
        1
    Masoud2023  
       159 天前
    没看懂你想干什么,感觉你可能不会做 python 依赖管理。

    pipx 这写的挺明白了吧:If you are attempting to install a library, pipx should not be used 。

    你正确的做法应该是 python -m virtualenv .venv 创建个虚拟环境,然后在环境里装你的依赖,然后用环境的 python 运行你的程序。
    wccc
        2
    wccc  
       159 天前   ❤️ 1
    pip install -U cos-python-sdk-v5 --break-system-packages
    joeyv2
        3
    joeyv2  
    OP
       159 天前
    @Masoud2023 cos-python-sdk-v5 是第三方库使用 pip install 安装提示如上,返回内容中有写到第三方库可以使用 pipx install xyz 自动创建虚拟环境并安装。还是说需要先执行 python3 -m 再执行怕 pipx install
    Masoud2023
        4
    Masoud2023  
       159 天前
    @joeyv2 #3 你能不能完整的说一下你想干什么,想做什么需求,只言片语这个我不知道接下来怎么指导,pip 行为最近新版改了,你做 python 程序不建虚拟环境肯定装不进去你项目需要用的依赖的,以前很多教程都没有提示这一点的。
    adoal
        5
    adoal  
       159 天前
    发行版打包的 Python 用了发行版的包管理规则,系统里有很多重要组件依赖它,你在上面直接 pip 安装可能会破坏系统。
    听#1 的,先创建一个 venv ,再在 venv 里用 pip 安装。
    joeyv2
        6
    joeyv2  
    OP
       159 天前
    @Masoud2023
    第一步:python3 -m venv path/to/venv
    第二步:path/to/venv/bin/pip install -U cos-python-sdk-v5
    这样来创建虚拟环境并安装第三方包,那么 pipx 命令的作用是什么?
    Masoud2023
        7
    Masoud2023  
       159 天前
    @joeyv2 #6

    https://pypa.github.io/pipx/

    pipx is a tool to help you install and run end-user applications written in Python

    你就当这东西是装现成的东西的,比如你装 poetry ,poetry 如果非拿 pip 装那就得拿 pipx 装( poetry 在一些 Linux 有现成的包可以装,我知道 arch 有,别的没试过)
    Masoud2023
        8
    Masoud2023  
       159 天前   ❤️ 1
    说白了就是

    pip -> 装依赖,项目里 import 的

    pipx -> 在系统里面装命令,不是项目 import 的
    UncleCAT4
        9
    UncleCAT4  
       101 天前
    pipx install 即可
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2766 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 06:36 · PVG 14:36 · LAX 23:36 · JFK 02:36
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.