TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: How come there is no one recommended way to setup Python environment?

1 点作者 sawirricardo9 个月前
If you ask this to 10 people, you can get 10 answers for that…<p>Cant we agree on how we can setup and start python?

4 条评论

ggm9 个月前
The most likely outcome at this point is more ways to do it not less. Because we&#x27;ve arrived at the point where nobody is willing to give up on their favourite method.<p>I think it may be in the class of things Python people COULD fix but WONT fix.<p>For me, the biggest bugbear is how often you need to work through pip not liking install frameworks like brew. It drives very strongly to telling you to &quot;virtualise&quot; but that means having link farms and context specific execution envirements baked into your praxis.<p>If (like me) you&#x27;re used to just vi &#x2F;tmp&#x2F;file.py and hacking, the burdens of pip not wanting to break things (tm) become high. Could e.g. python not have SYSPATH:OTHERPATH:VERSION-SPECIFIC-PATH:~&#x2F;.PYENV: included in it, so we can install pip stuff in homedirs and not have to worry about smashing the system install? (avalanche of &quot;bad idea because..&quot; coming)<p>Perl kind of had this. You can live with old perl libs through at most one ENV setting to point to your install path.
评论 #41360433 未加载
samier-trellis9 个月前
My bet is that within the next year, people will coalesce around uv.
评论 #41357834 未加载
apothegm9 个月前
There’s an XKCD about that…
zahlman9 个月前
I&#x27;d like to zoom out to the overall task of packaging, first. Here, there are a lot of contributing factors.<p>1. Backwards compatibility concerns. Python devs hate churn in general, and the ones responsible for major projects like Pip seem traumatized by the 2-&gt;3 migration in particular (they not only had to make their own code work, but get pieces to work together in an era before &quot;ecosystem&quot; was even a common buzzword, and deal with complaints from clients).<p>2. Everyone agrees that &quot;there should be one way to do it&quot;, per the Zen. But there is very little agreement on what&#x27;s actually included in &quot;it&quot;, and no agreement on how those tasks should (or may) be distributed across tools. Some people advocate for all-in-one solutions, others for the Unix philosophy. (My personal conclusion is that <i>users</i> should have an integrated tool for every common user-facing task, while <i>devs</i> should add to that with individual tools for individual dev tasks.)<p>3. The distinction between &quot;applications&quot; and &quot;libraries&quot; in Python is subtle, but hasn&#x27;t been very well addressed. People have tried for years (and are currently trying again) to figure out a standard for lock files. Pipx smooths over the gap between library and application installation requirements by holding on to its own copy of Pip and using it (through perfectly well documented, but under-appreciated command-line flags) to install into specific environments which it creates (with the standard library `venv`). But while it <i>could</i> function as a manager for those two tools, it artificially restricts itself <i>not</i> to install libraries into a venv that doesn&#x27;t already contain an application.<p>4. Python libraries have to handle a lot of extensions written in other languages. Sometimes it&#x27;s necessary to compile those on the user&#x27;s machine, and people want that process to be fully automated - but that leaves the problem of how to specify build-time requirements that have nothing to do with Python (for example, a C compiler).<p>5. The standard tools have a bunch of random limitations and flaws, and nobody agrees on what&#x27;s worth fixing or how to fix it. I could probably rant for hours about this.<p>6. Linux distros (especially Debian and everything downstream of it) provide Python because they want to use Python to provide essential services - <i>not</i> so that the user can have the experience of using Python according to how the official documentation says it&#x27;s supposed to work.<p>If you&#x27;re talking specifically from the user&#x27;s side: Pip and venv are still the defaults. It&#x27;s worth learning how to use them better: you can tell `venv` to exclude Pip from the new environment, and you can tell a single globally-installed Pip which environment to install into. (<i>There won&#x27;t ever be any getting around understanding the concept of an environment</i>, because if you have countless third parties offering libraries, there&#x27;s no way to assure that they&#x27;ll all play nice with each other.) You can ignore the system package manager completely (except for possibly installing packages to give you Pip and venv). You can make your own wrappers to auto-activate environments on some trigger, or to detect an environment based on the PWD and&#x2F;or the path to the code. But I agree that there are a lot of rough edges here, which is part of why I&#x27;ve been designing my own competitor (no GitHub repo for it yet; I&#x27;m hoping to have <i>something</i> before the end of the year, but other projects are a priority for me).<p>If you&#x27;re talking specifically about <i>installing Python itself</i> - as far as python.org is concerned, the standard way on Windows and Mac is to run their installer, and the standard way on Linux is to install from source using their source tarball. Tools like Pyenv are really just wrappers around this. (I can&#x27;t comment on Homebrew as it&#x27;s been about 20 years since I owned a Mac.)<p>If you&#x27;re talking about <i>choosing between installations to run</i>, this is also pretty standard, although the standard again has flaws. I&#x27;ve written about this at <a href="https:&#x2F;&#x2F;software.codidact.com&#x2F;posts&#x2F;291616&#x2F;" rel="nofollow">https:&#x2F;&#x2F;software.codidact.com&#x2F;posts&#x2F;291616&#x2F;</a> .