question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Permission error when running from browser

See original GitHub issue

Hi, basically I have created a script that launches Ocrmypdf.

$c = ('ocrmypdf -l lav --rotate-pages --pdf-renderer tesseract --output-type pdf --sidecar output.txt input.pdf output.pdf');');
exec($c, $output);
print_r($output)

When I try to call the PHP script from the server itself: php ocr.php I get the intended result.

However, when I try to open it and run from browser, I got the following permission error:

Traceback (most recent call last):
  File "/usr/local/bin/ocrmypdf", line 7, in <module>
    from ocrmypdf.__main__ import run_pipeline
  File "/usr/lib/python3.6/site-packages/ocrmypdf/__init__.py", line 3, in <module>
    import pkg_resources
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3019, in <module>
    @_call_aside
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3003, in _call_aside
    f(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 3032, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 646, in _build_master
    ws = cls()
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 639, in __init__
    self.add_entry(entry)
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 695, in add_entry
    for dist in find_distributions(entry, True):
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2019, in find_on_path
    path_item, entry, metadata, precedence=DEVELOP_DIST
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2432, in from_location
    py_version=py_version, platform=platform, **kw
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2772, in _reload_version
    md_version = _version_from_file(self._get_metadata(self.PKG_INFO))
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2397, in _version_from_file
    line = next(iter(version_lines), '')
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2565, in _get_metadata
    for line in self.get_metadata_lines(name):
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1467, in get_metadata_lines
    return yield_lines(self.get_metadata(name))
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1463, in get_metadata
    value = self._get(self._fn(self.egg_info, name))
  File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1572, in _get
    with open(path, 'rb') as stream:
PermissionError: [Errno 13] Permission denied: '/usr/lib/python3.6/site-packages/ruffus-2.6.3-py3.6.egg-info/PKG-INFO'

/usr/local/bin/ocrmypdf

cat /usr/local/bin/ocrmypdf

#!/usr/bin/python3.6

import re
import sys

from ocrmypdf.__main__ import run_pipeline

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
    sys.exit(run_pipeline())`

OS: Centos 7.

I’m aware that this may not be strictly OCRMYPDF related issue. But it is quite strange that I continue to get this error even when (for testing purposed) did CHMOD/CHOWN whole Python directory to more open permissions. My initial impression is that that some of those packages require higher user access?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
jbarlow83commented, Nov 21, 2017

It should be fine for an intranet, just not a space where people could deliberately try to break it.

Temporary storage usage is linear with the number of pages in the PDF so you can usually handle hundreds of pages before that is an issue.

On Nov 21, 2017 07:42, “Gugols” notifications@github.com wrote:

@jbarlow83 https://github.com/jbarlow83 It would be used in intranet where just a few selected editors will be able upload those scanned PDFs. What alternative/approach would you suggest? As to the resource usage, we could add additional server just for OCR task. Basically, we have Drupal site which uses Solr to index content. We have tackled the task of getting PDF metadata, but scanned documents still is an issue (they need to be OCR and indexed for search). I have tested a lot of OCR libraries, and to be honest - only OCRMYPDF seemed like a solid, capable solution.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jbarlow83/OCRmyPDF/issues/201#issuecomment-346066652, or mute the thread https://github.com/notifications/unsubscribe-auth/ABvcMw8lYvCdHNbP_BFpUI0OqRoIdh30ks5s4u92gaJpZM4Ql2zu .

0reactions
jbarlow83commented, Nov 27, 2017

I’ll close the issue now since the main concern seemed to be a platform configuration issue. If you have further related questions feel free to reopen it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fix “Access Denied, You Don't Have Permission To Access on ...
The “Access Denied” error appears when your browser uses different proxy settings or VPN instead of what's really set on your Windows 10...
Read more >
What Is the 403 Forbidden Error and How to Fix It (8 Methods ...
A common cause of these errors is the file or folder permission settings, which control who can read, write, and execute the file...
Read more >
Permission denied if reading Location object property
This article provides many methods for you to solve the Permission denied error message that occurs if you read properties of the Location ......
Read more >
Download Failed - Insufficient Permissions Error in Chrome
Download Failed - Insufficient Permissions error in Google Chrome occurs due to the browser being unable to write to its default save location....
Read more >
Error: Permission denied to access property "x" - JavaScript
The JavaScript exception "Permission denied to access property" occurs when there was an attempt to access an object for which you have no ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found