binary-husky/gpt_academic · error · PermissionError

No read permission: {path}

Error message

No read permission: {path}

What it means

Third check in ExcelTextExtractor._validate_file: os.access(path, os.R_OK) is false, so PermissionError('No read permission: <path>') is raised. The file exists and is a file, but the current process's effective user lacks read permission (or, on some setups, the path is unreadable via ACL even though it looks fine in ls).

Source

Thrown at crazy_functions/doc_fns/read_fns/excel_reader.py:79

            with open(file_path, 'rb') as f:
                raw_data = f.read(10000)
                result = chardet.detect(raw_data)
                return result['encoding'] or 'utf-8'
        except Exception as e:
            self.logger.warning(f"Encoding detection failed: {e}. Using utf-8")
            return 'utf-8'

    def _validate_file(self, file_path: Union[str, Path]) -> Path:
        path = Path(file_path).resolve()

        if not path.exists():
            raise ValueError(f"File not found: {path}")

        if not path.is_file():
            raise ValueError(f"Not a file: {path}")

        if not os.access(path, os.R_OK):
            raise PermissionError(f"No read permission: {path}")

        if path.suffix.lower() not in self.SUPPORTED_EXTENSIONS:
            raise ValueError(
                f"Unsupported format: {path.suffix}. "
                f"Supported: {', '.join(sorted(self.SUPPORTED_EXTENSIONS))}"
            )

        return path

    def _format_value(self, value: Any) -> str:
        if pd.isna(value) or value is None:
            return ''
        if isinstance(value, (int, float)):
            return str(value)
        return str(value).strip()

    def _process_chunk(self, chunk: pd.DataFrame, columns: Optional[List[str]] = None, sheet_name: str = '') -> str:
        """处理数据块,新增sheet_name参数"""

View on GitHub (pinned to d6bde0fa54)

Solutions

  1. Check ownership and mode: ls -l <path>; compare with the process UID (id)
  2. Grant read: chmod +r <path> (or chown to the running user) — in Docker, match UID or set appropriate file permissions on the mount
  3. On Windows, adjust the file ACL for the service user
  4. Run the reading process under an account with access
Defensive patterns

Strategy: validation

Validate before calling

import os

if not os.access(fp, os.R_OK):
    raise PermissionError(f'grant read on {fp} before extraction')

Try / catch

try:
    text = extractor.read_text(fp)
except PermissionError as e:
    notify_ops(f'fix perms: chmod +r {e}')  # message contains the path
    raise

Prevention

When it happens

Trigger: File owned by another user with mode 600; process running as a different user (docker container vs host file); Windows read-only/ACL-denied files; files under /proc-like pseudo filesystems.

Common situations: Docker bind-mounts where the container UID differs from the host file owner; files created by a service account; macOS/Linux group permission mismatches.

Related errors


AI-assisted analysis of binary-husky/gpt_academic@d6bde0fa54 (2026-08-14). Data as JSON: /api/errors/21a8f8458396dda9. Report an issue: GitHub.