Python: Difference between revisions

DHCP (talk | contribs)
m fix the language parameter in {{file}} template
Bittner (talk | contribs)
Suggest HM's programs.uv option and nix-ld
 
Line 403: Line 403:


<syntaxhighlight lang="console">
<syntaxhighlight lang="console">
$ uv python install 3.14 --preview --default
$ uv python install 3.14 --default
</syntaxhighlight>
</syntaxhighlight>


You may want to set the <code>UV_PYTHON_DOWNLOADS=never</code> environment variable in your shell to stop uv from downloading Python binaries automatically if needed. Setting <code>environment.localBinInPath = true;</code> is highly recommended, because uv will install binaries in <code>~/.local/bin</code>.
Setting <code>environment.localBinInPath = true;</code> is highly recommended, because uv will install binaries in <code>~/.local/bin</code>.
 
==== Python software development ====
Python is meant to be considered a ''development'' package. That said, avoid installing a ''system'' Python for developing on Python projects. Consider using Home Manager's [https://nix-community.github.io/home-manager/options/home-manager/programs/uv.html <code>programs.uv</code>] instead that does Python and Python tool installations with continuous, automatic updates.
 
==== ImportError: libstdc++.so.6 ====
If you hit the infamous <code>ImportError: libstdc++.so.6: cannot open shared object file: No such file or directory</code> error after installing a Python package make sure to configure <code>nix-ld</code> (see above) to patch packages that expect an [[wikipedia:Filesystem_Hierarchy_Standard|FHS compliant]] environment. See [https://painless.software/how-use-python-on-nixos-the-pythonic-way this blog post] for background reading.


=== Using poetry ===
=== Using poetry ===