Python: Difference between revisions

imported>Melkor333
Add link to fix-python
imported>IgorM
m Fixed syntax highlighting
Line 174: Line 174:


We can now build with:
We can now build with:
<syntaxhighlight>
<syntaxhighlight lang=console>
$ nix-build
$ nix-build
[...]
[...]
Line 182: Line 182:
</syntaxhighlight>
</syntaxhighlight>
or just enter a nix-shell, and directly execute your program or python if it's easier to develop:
or just enter a nix-shell, and directly execute your program or python if it's easier to develop:
<syntaxhighlight>
<syntaxhighlight lang=console>
$ nix-shell
$ nix-shell
[...]
[...]
Line 208: Line 208:


Put your packages in a requirements.txt:
Put your packages in a requirements.txt:
<syntaxhighlight>
<syntaxhighlight lang=text>
pandas
pandas
requests
requests
Line 326: Line 326:


To activate an environment you will need a [https://nixos.org/manual/nixpkgs/stable/#sec-fhs-environments FHS environment] e.g.:
To activate an environment you will need a [https://nixos.org/manual/nixpkgs/stable/#sec-fhs-environments FHS environment] e.g.:
<syntaxhighlight lang="shell">
<syntaxhighlight lang="console">
$ nix-shell -E 'with import <nixpkgs> {}; (pkgs.buildFHSUserEnv { name = "fhs"; }).env'
$ nix-shell -E 'with import <nixpkgs> {}; (pkgs.buildFHSUserEnv { name = "fhs"; }).env'
$ eval "$(micromamba shell hook -s bash)"
$ eval "$(micromamba shell hook -s bash)"
Line 422: Line 422:


Or, if you want to use matplotlib interactively:
Or, if you want to use matplotlib interactively:
<syntaxhighlight lang=shell>
<syntaxhighlight lang=console>
$ nix-shell -p gobject-introspection gtk3 'python36.withPackages(ps : with ps; [ matplotlib pygobject3 ipython ])'
$ nix-shell -p gobject-introspection gtk3 'python36.withPackages(ps : with ps; [ matplotlib pygobject3 ipython ])'
$ ipython
$ ipython