Skip to content
This repository has been archived by the owner on Feb 19, 2021. It is now read-only.

FileNotFoundError: [Errno 2] No such file or directory: '/usr/bin/convert' #43

Closed
Adrenocortico opened this issue Feb 17, 2016 · 10 comments

Comments

@Adrenocortico
Copy link

Hi, when I run ./manage.py document_consumer this come out (OS X El Capitan)
Traceback (most recent call last): File "./manage.py", line 18, in <module> execute_from_command_line(sys.argv) File "/Users/Francesco/Library/Python/3.5/lib/python/site-packages/django/core/management/__init__.py", line 350, in execute_from_command_line utility.execute() File "/Users/Francesco/Library/Python/3.5/lib/python/site-packages/django/core/management/__init__.py", line 342, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/Users/Francesco/Library/Python/3.5/lib/python/site-packages/django/core/management/base.py", line 348, in run_from_argv self.execute(*args, **cmd_options) File "/Users/Francesco/Library/Python/3.5/lib/python/site-packages/django/core/management/base.py", line 399, in execute output = self.handle(*args, **options) File "/Users/Francesco/Desktop/paperless-master/src/documents/management/commands/document_consumer.py", line 49, in handle self.loop() File "/Users/Francesco/Desktop/paperless-master/src/documents/management/commands/document_consumer.py", line 59, in loop self.file_consumer.consume() File "/Users/Francesco/Desktop/paperless-master/src/documents/consumer.py", line 116, in consume pngs = self._get_greyscale(tempdir, doc) File "/Users/Francesco/Desktop/paperless-master/src/documents/consumer.py", line 139, in _get_greyscale "-type", "grayscale", doc, png File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py", line 950, in __init__ restore_signals, start_new_session) File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/subprocess.py", line 1544, in _execute_child raise child_exception_type(errno_num, err_msg) FileNotFoundError: [Errno 2] No such file or directory: '/usr/bin/convert'

I've installed pip3 requirements from requirements.txt.

@pitkley
Copy link
Member

pitkley commented Feb 17, 2016

As stated in the requirements, you have to install ImageMagick which contains the missing convert binary.

Other users under OS X also had to install ghostscript to make things work, see here and issue #25.

If after installing these dependencies you still get the error message above, you might have to adapt the CONVERT_BINARY variable in settings.py to possibly /usr/local/bin/convert.

@Adrenocortico
Copy link
Author

I've installed also ImageMagick and ghostscript but it continues not to work.

@pitkley
Copy link
Member

pitkley commented Feb 17, 2016

If you open your Terminal and enter which convert, do you get a path to a binary returned? If so, be sure to use that path and set it in your settings.py as mentioned above!

@Adrenocortico
Copy link
Author

Ok! Using /usr/local/bin/convert in CONVERT_BINARY it works! Thank you so much!

@pitkley
Copy link
Member

pitkley commented Feb 17, 2016

No problem, glad I could help!

@pitkley
Copy link
Member

pitkley commented Feb 17, 2016

@danielquinn Should we maybe do something like this and rely on the binary being on the path by default?

diff --git a/src/documents/consumer.py b/src/documents/consumer.py
index 5ca4281..f7791b1 100644
--- a/src/documents/consumer.py
+++ b/src/documents/consumer.py
@@ -50,7 +50,7 @@ class Consumer(object):
     """

     SCRATCH = settings.SCRATCH_DIR
-    CONVERT = settings.CONVERT_BINARY
+    CONVERT = settings.CONVERT_BINARY if settings.CONVERT_BINARY else "convert"
     CONSUME = settings.CONSUMPTION_DIR
     THREADS = int(settings.OCR_THREADS) if settings.OCR_THREADS else None

diff --git a/src/paperless/settings.py b/src/paperless/settings.py
index 4449899..f853c5f 100644
--- a/src/paperless/settings.py
+++ b/src/paperless/settings.py
@@ -159,7 +159,8 @@ FORGIVING_OCR = True
 GNUPG_HOME = os.environ.get("HOME", "/dev/null")

 # Convert is part of the Imagemagick package
-CONVERT_BINARY = "/usr/bin/convert"
+# If it is not on your PATH, you can specify the absolut path to the binary here
+CONVERT_BINARY = None

 # This will be created if it doesn't exist
 SCRATCH_DIR = "/tmp/paperless"

@danielquinn
Copy link
Collaborator

I had a similar thought when I saw this issue come up, but I think it might be best to just set settings.CONVERT_BINARY = os.environ("PAPERLESS_CONVERT", "convert"). That way the user can change the value in settings.py explicitly or set it with an environment variable in a wrapper or something. The default will always just look for convert in $PATH. It also means that what you see in settings.py is what you get, rather than having consumer.py make that decision. Does that sound cool with you?

@pitkley
Copy link
Member

pitkley commented Feb 17, 2016

Yes, good thinking.

On the topic of naming the environment variable, should we try to name them like the variables, only prefixed with PAPERLESS_? Right now we have:

settings.py Environment variable
OCR_THREADS PAPERLESS_OCR_THREADS
FORGIVING_OCR none
CONVERT_BINARY PAPERLESS_CONVERT
SCRATCH_DIR none
CONSUMPTION_DIR PAPERLESS_CONSUME
MAIL_CONSUMPTION PAPERLESS_CONSUME_MAIL_*
PASSPHRASE PAPERLESS_PASSPHRASE
UPLOAD_SHARED_SECRET PAPERLESS_SECRET

Maybe renaming one or the other to make them match might be worth thinking about and possibly adding missing ones.

@danielquinn
Copy link
Collaborator

There you go again, being all rational :-P

This is an excellent point. I'll create an issue and point it to this comment and will get to it soon.

@pitkley
Copy link
Member

pitkley commented Feb 17, 2016

Sorry ;)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants