mach-nix
mach-nix copied to clipboard
Can't import camelot?
I tried to use mach-nix to load camelot… but it seems that it's not working as I get an error ModuleNotFoundError: No module named 'camelot'. Am I just doing something wrong (in which case it may worth updating the documentation), or is it something else?
$ cat shell.nix
let
mach-nix = import (builtins.fetchGit {
url = "https://github.com/DavHau/mach-nix/";
# place version number with the latest one from the github releases page
ref = "refs/tags/3.4.0";
}) {};
in
mach-nix.mkPython {
# contents of a requirements.txt (use builtins.readFile ./requirements.txt alternatively)
requirements = ''
camelot-py
'';
}
$ nix-shell
trace: removing dependency python3.9-packaging-21.3 from cryptography
trace:
applying fix 'no-rust-build' (nativeBuildInputs) for cryptography:3.3.2
trace: removing dependency python3.9-setuptools-rust-0.12.1 from cryptography
[nix-shell]$ python
Python 3.9.11 (main, Mar 16 2022, 13:56:23)
[GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import camelot
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'camelot'
>>>
You need to use mach-nix.mkPythonShell:
let
mach-nix = import (builtins.fetchGit {
url = "https://github.com/DavHau/mach-nix/";
# place version number with the latest one from the github releases page
ref = "refs/tags/3.4.0";
}) {};
in
mach-nix.mkPythonShell {
# contents of a requirements.txt (use builtins.readFile ./requirements.txt alternatively)
requirements = ''
camelot-py
'';
}
Oh, sorry, thanks. So I tried to do that, but then I get an error can't import cv2. However, if I install opencv manually, then I get another issue here. But, when looking at the doc, pip specifies that we need to install camelot-py[base] (no idea if base must be replaced with anything). But if I use:
let
mach-nix = import (builtins.fetchGit {
url = "https://github.com/DavHau/mach-nix/";
# place version number with the latest one from the github releases page
ref = "refs/tags/3.4.0";
}) {};
in
mach-nix.mkPythonShell {
# contents of a requirements.txt (use builtins.readFile ./requirements.txt alternatively)
requirements = ''
camelot-py[base]
'';
ignoreCollisions = true;
}
then the system stays forever in the state pythonImportsCheckPhase:
Finished executing pythonRemoveTestsDir
pythonCatchConflictsPhase
pythonRemoveBinBytecodePhase
pythonImportsCheckPhase
Executing pythonImportsCheckPhase
I tried to use:
let
mach-nix = import (builtins.fetchGit {
url = "https://github.com/DavHau/mach-nix/";
# place version number with the latest one from the github releases page
ref = "refs/tags/3.4.0";
}) {};
in
mach-nix.mkPythonShell {
# contents of a requirements.txt (use builtins.readFile ./requirements.txt alternatively)
requirements = ''
camelot-py[base]
'';
ignoreCollisions = true;
dontUsePythonImportsCheck = true;
}
to avoid that, but apparently dontUsePythonImportsCheck can't be used this way…
Interesting, you first shell.nix worked for me, even without ignoreCollisions = true.
I finally got a working solution:
let
mach-nix = import (builtins.fetchGit {
url = "https://github.com/DavHau/mach-nix/";
# place version number with the latest one from the github releases page
ref = "refs/tags/3.4.0";
}) {};
in
mach-nix.mkPythonShell {
# contents of a requirements.txt (use builtins.readFile ./requirements.txt alternatively)
requirements = ''
camelot-py[base]
'';
ignoreCollisions = true;
_.pdftopng.dontUsePythonImportsCheck = true;
}
Not sure why dontUsePythonImportsCheck is required to avoid the freeze…
$ python3
Python 3.9.9 (main, Nov 15 2021, 18:05:17)
[GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import camelot
>>>