I have a Python workflow that reads local folders, uploads pix to google cloud for processing, and returns json files back to other local folders. This workflow worked fine.
I used this script:
#!/bin/bash
# Create and activate a Python virtual environment
python -m venv dg_ocr_env
source dg_ocr_env/bin/activate
# Deactivate any existing Conda environment
conda deactivate
# Upgrade pip
python -m pip install --upgrade pip
# Install packages from requirements.txt
pip install -r /Users/XXXX/Desktop/ocv/00_setup_VENV_dg_ocr/requirements.txt
...and I was then able to run my main.py script without error.
Then, I tried dockerizing and hit this:
ModuleNotFoundError: No module named 'indexer'
I thought this might've had something to do with Docker only…whether individual build or docker compose, rebuilding with no cache (and every other way I have found scouring the Internet), I got the following error or something like it:
docker run ocr-image
Traceback (most recent call last):
File "/app/unified_ocr_2_json.py", line 15, in <module>
from spellchecker import SpellChecker
File "/usr/local/lib/python3.9/site-packages/spellchecker/__init__.py", line 2, in <module>
from spellchecker.core import Spellchecker,getInstance
File "/usr/local/lib/python3.9/site-packages/spellchecker/core.py", line 26, in <module>
from indexer import DictionaryIndex
ModuleNotFoundError: No module named 'indexer'
what I tried: In trying to get some clarity on the process, I wiped another computer, set up a clean Monterey operating system, and installed nothing in it except for Anaconda, Brew, and sublime.txt.
I then tried to recreate from my directory of py scripts, etc., i,e., the workflow that had a very short time ago worked just fine locally:
I ran my .sh (shown above): …and now here is the most recent traceback from the clean computer:
python /Users/aiki/Desktop/ocv/unified_ocr_2_json.py
Traceback (most recent call last):
File "/Users/aiki/Desktop/ocv/unified_ocr_2_json.py", line 11, in <module>
from spellchecker import SpellChecker
File "/Users/aiki/opt/anaconda3/lib/python3.9/site-packages/spellchecker/__init__.py", line 2, in <module>
from spellchecker.core import Spellchecker,getInstance
File "/Users/aiki/opt/anaconda3/lib/python3.9/site-packages/spellchecker/core.py", line 26, in <module>
from indexer import DictionaryIndex
ModuleNotFoundError: No module named 'indexer'
My script.py calls:
from spellchecker import SpellChecker
Here is pip show spellchecker:
(dg_ocr_env) aware@awares-MacBook-Pro spellchecker % ls
__init__.py core.py indexer.py langdetect.py resources templates
__pycache__ dicts info.py py.typed spellchecker.py utils.py
(dg_ocr_env) aware@awares-MacBook-Pro spellchecker %
and nano core.py:
#
import os
import string
import codecs
import inexactsearch
import urllib
from indexer import DictionaryIndex
from langdetect import _detect_lang
__all__ = ['Spellchecker', 'getInstance']
I have looked inside core.py (indexer is there...), I have checked dependency conflicts, I have checked requirements.txt and what spellchecker says it requires is listed, And so so much more -
I have no idea what changed, all I know is: what used to work on one computer locally, now no longer works on either computer locally, let alone in any kind of docker container.
Any help at all will be greatly appreciated, thank you!