V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐学习书目
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
entimm
V2EX  ›  Python

关于 Python 的一些疑问

  •  
  •   entimm · Oct 18, 2023 · 2402 views
    This topic created in 926 days ago, the information mentioned may be changed or developed.

    python 项目的 python 版本问题

    我看到大多数的 python 项目都没有说明项目需要运行在什么版本的 python 环境,所以导致在尝试运行的时候也经常报错,不过我也看到有些项目是在有一个 runtime.txt 的文件来写明 python 版本 python 的不同版本之间不太兼容,没有统一的方式标明项目所需的 python 版本,那么我怎么知道该创建什么版本的虚拟环境呢

    python 项目的依赖管理问题

    python 项目当前好像并没有 php 的 composer 、js 的 npm 这样的包管理工具,我看到很多 github 的 python 项目都是用 requirements.txt 来管理 python 的依赖,不过还是有相当多的项目根本就没有 requirements.txt ,,所以很多 python 项目在 clone 下来尝试运行的时候,经常就是报找不到包,然后我只能遇到一个相关报错就安装一个

    以上两个问题让我非常困惑,麻烦懂的大佬帮忙解解惑

    10 replies    2023-10-18 12:31:16 +08:00
    TArysiyehua
        1
    TArysiyehua  
       Oct 18, 2023
    以前野蛮生长,现在一般都要求要 requirements.txt
    TArysiyehua
        2
    TArysiyehua  
       Oct 18, 2023
    有 pyproject.toml 或者 runtime.txt 来定义 python 版本
    Hstar
        3
    Hstar  
       Oct 18, 2023
    你找的都是什么 python 项目啊,已经很少有这样不友好的开源库了。
    要么是在文档里指定 python > 3.7 或者 python <= 3.7 ,要么就是语法简单,完全兼容 python3 。
    requirements.txt 是比较老的依赖管理途径了,不支持指定 python 版本,但比较新的 pipenv 或者 poetry 都可以啦。
    thinkershare
        4
    thinkershare  
       Oct 18, 2023   ❤️ 1
    没有办法知道,python 的依赖管理就是一坨狗屎。
    lplk
        5
    lplk  
       Oct 18, 2023
    我毕业以来项目都会写 dockerfile ,编译好一般直接能跑,通过 dockerfile 就可以看到依赖的环境了。
    hadugen
        6
    hadugen  
       Oct 18, 2023
    pyenv 管理 python version,
    hadugen
        7
    hadugen  
       Oct 18, 2023
    @tomtao00001 #5 pdm 管理项目依赖
    makerbi
        8
    makerbi  
       Oct 18, 2023
    我现在新项目都在用 PDM 管理了,开发测试生产都没啥问题
    julyclyde
        9
    julyclyde  
       Oct 18, 2023
    持续维护的软件应该会逐渐跟随 python 的主要版本
    并在自己的安装包里写明兼容的版本范围

    至于缺乏维护的……建议别沾他们
    cmdOptionKana
        10
    cmdOptionKana  
       Oct 18, 2023
    > 大多数的 python 项目都没有说明项目需要运行在什么版本的 python 环境

    这个前提就错了,后面的就没必要讨论了。

    因为大多数 python 项目都会明确版本,自然没啥大问题。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   997 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 42ms · UTC 18:15 · PVG 02:15 · LAX 11:15 · JFK 14:15
    ♥ Do have faith in what you're doing.