Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A confusing question about: RuntimeError: Directory 'static/' does not exist when mounting static files, and how I solve this problem #5

Open
GinterFu opened this issue Jan 13, 2025 · 0 comments

Comments

@GinterFu
Copy link

Description

When importing packages during development, I mistakenly installed the fitz package instead of PyMuPDF. Initially, I didn't realize this mistake until I encountered some runtime errors. Afterward, I corrected this by installing PyMuPDF. However, after configuring all global variables, I encountered the following error:

Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  ...
  File "F:\a\b\c\lib\site-packages\starlette\staticfiles.py", line 56, in __init__
    raise RuntimeError(f"Directory '{directory}' does not exist")
RuntimeError: Directory 'static/' does not exist

Allow me to hide some information about project path, Please.
These errors were extremely confusing because they originated from the package source code itself.

Solution

After searching online, I discovered the root cause of this issue on a Stack Overflow post. The issue was caused by the fitz package, which is incompatible with Python >= 3.8.

The solution is straightforward:

Uninstall the incorrect fitz package:

pip uninstall fitz

Install the correct PyMuPDF package:

pip install PyMuPDF

Proposed Enhancement

To prevent similar issues in the future, I suggest improving the installation process:

  • Use a file or similar mechanism to clearly specify the required packages for the project.
    • Just like a better requirements.txt or pyproject.toml
  • Provide documentation or comments to guide users to install the correct package versions.
    This approach would help avoid confusion and prevent similar "false installations" from happening again.

Environment

  • OS: Windows 10
  • Python Version: 3.9.x
  • Relevant Packages:
    • Incorrect: fitz
    • Correct: PyMuPDF

Let me know if any additional details are required to address this issue. Thanks! 😊

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

No branches or pull requests

1 participant