Closed LexiconCode closed 3 years ago
I think the second issue is caused by naming your test script screen_ocr.py. Try naming it something else.
I'm not sure why python -m screen_ocr
isn't working. I just tested it myself and it works. Are you sure you've upgraded to the latest version of the package? Perhaps this is caused by the above issue as well, if you're running the command from the directory with your screen_ocr.py script.
I think the second issue is caused by naming your test script screen_ocr.py. Try naming it something else.
Yes that solved Partially initialized module 'screen_ocr'
To test completely removed python (including modules) from my test environment on the laptop. I originally was on my desktop.
Reinstalled python 3.9.5 64-bit:
How ever not did not fix python -m screen_ocr
.
I see that screen-ocr-0.1.0
is installed not screen_ocr-0.1.1
.
PS C:\Users\MainLaptop> pip install screen-ocr[winrt] --no-cache-dir
Collecting screen-ocr[winrt]
Downloading screen_ocr-0.1.1-py2.py3-none-any.whl (12 kB)
....
Collecting screen-ocr[winrt]
Downloading screen_ocr-0.1.0-py2.py3-none-any.whl (12 kB)
WARNING: screen-ocr 0.1.0 does not provide the extra 'winrt'
Whats going on with pip? Looks as if screen_ocr is downloaded as screen-ocr-0.1.1
then screen_ocr-0.1.0
.
pip 21.1.2 from c:\users\mainlaptop\appdata\local\programs\python\python39\lib\site-packages\pip (python 3.9)
PS C:\Users\MainLaptop> pip install screen-ocr[winrt] --no-cache-dir
Collecting screen-ocr[winrt]
Downloading screen_ocr-0.1.1-py2.py3-none-any.whl (12 kB)
Collecting pillow
Downloading Pillow-8.2.0-cp39-cp39-win_amd64.whl (2.2 MB)
|████████████████████████████████| 2.2 MB 2.2 MB/s
Collecting numpy
Downloading numpy-1.21.0-cp39-cp39-win_amd64.whl (14.0 MB)
|████████████████████████████████| 14.0 MB ...
Collecting scikit-image
Downloading scikit_image-0.18.1-cp39-cp39-win_amd64.whl (12.2 MB)
|████████████████████████████████| 12.2 MB ...
Collecting pandas
Downloading pandas-1.2.5-cp39-cp39-win_amd64.whl (9.3 MB)
|████████████████████████████████| 9.3 MB ...
Collecting rapidfuzz
Downloading rapidfuzz-1.4.1-cp39-cp39-win_amd64.whl (430 kB)
|████████████████████████████████| 430 kB ...
Collecting screen-ocr[winrt]
Downloading screen_ocr-0.1.0-py2.py3-none-any.whl (12 kB)
WARNING: screen-ocr 0.1.0 does not provide the extra 'winrt'
Collecting pytesseract
Downloading pytesseract-0.3.7.tar.gz (13 kB)
Collecting python-dateutil>=2.7.3
Downloading python_dateutil-2.8.1-py2.py3-none-any.whl (227 kB)
|████████████████████████████████| 227 kB 6.4 MB/s
Collecting pytz>=2017.3
Downloading pytz-2021.1-py2.py3-none-any.whl (510 kB)
|████████████████████████████████| 510 kB 6.8 MB/s
Collecting six>=1.5
Downloading six-1.16.0-py2.py3-none-any.whl (11 kB)
Collecting imageio>=2.3.0
Downloading imageio-2.9.0-py3-none-any.whl (3.3 MB)
|████████████████████████████████| 3.3 MB 6.4 MB/s
Collecting PyWavelets>=1.1.1
Downloading PyWavelets-1.1.1-cp39-cp39-win_amd64.whl (4.2 MB)
|████████████████████████████████| 4.2 MB 6.4 MB/s
Collecting tifffile>=2019.7.26
Downloading tifffile-2021.6.14-py3-none-any.whl (169 kB)
|████████████████████████████████| 169 kB ...
Collecting scipy>=1.0.1
Downloading scipy-1.7.0-cp39-cp39-win_amd64.whl (33.8 MB)
|████████████████████████████████| 33.8 MB 6.4 MB/s
Collecting networkx>=2.0
Downloading networkx-2.5.1-py3-none-any.whl (1.6 MB)
|████████████████████████████████| 1.6 MB ...
Collecting matplotlib!=3.0.0,>=2.0.0
Downloading matplotlib-3.4.2-cp39-cp39-win_amd64.whl (7.1 MB)
|████████████████████████████████| 7.1 MB ...
Collecting kiwisolver>=1.0.1
Downloading kiwisolver-1.3.1-cp39-cp39-win_amd64.whl (51 kB)
|████████████████████████████████| 51 kB ...
Collecting pyparsing>=2.2.1
Downloading pyparsing-2.4.7-py2.py3-none-any.whl (67 kB)
|████████████████████████████████| 67 kB 2.3 MB/s
Collecting cycler>=0.10
Downloading cycler-0.10.0-py2.py3-none-any.whl (6.5 kB)
Collecting decorator<5,>=4.3
Downloading decorator-4.4.2-py2.py3-none-any.whl (9.2 kB)
Using legacy 'setup.py install' for pytesseract, since package 'wheel' is not installed.
Installing collected packages: six, python-dateutil, pyparsing, pillow, numpy, kiwisolver, decorator, cycler, tifffile, scipy, PyWavelets, pytz, networkx, matplotlib, imageio, scikit-image, rapidfuzz, pytesseract, pandas, screen-ocr
Running setup.py install for pytesseract ... done
Successfully installed PyWavelets-1.1.1 cycler-0.10.0 decorator-4.4.2 imageio-2.9.0 kiwisolver-1.3.1 matplotlib-3.4.2 networkx-2.5.1 numpy-1.21.0 pandas-1.2.5 pillow-8.2.0 pyparsing-2.4.7 pytesseract-0.3.7 python-dateutil-2.8.1 pytz-2021.1 rapidfuzz-1.4.1 scikit-image-0.18.1 scipy-1.7.0 screen-ocr-0.1.0 six-1.16.0 tifffile-2021.6.14
Do to screen-ocr 0.1.0
EasyOCR not supported.
Traceback (most recent call last):
File "c:\Users\MainLaptop\Desktop\test.py", line 5, in <module>
results = ocr_reader.read_nearby(screen_coordinates=(0,0))
File "C:\Users\MainLaptop\AppData\Local\Programs\Python\Python39\lib\site-packages\screen_ocr\_screen_ocr.py", line 116, in read_nearby
return self.read_image(screenshot,
File "C:\Users\MainLaptop\AppData\Local\Programs\Python\Python39\lib\site-packages\screen_ocr\_screen_ocr.py", line 123, in read_image
result = self._backend.run_ocr(preprocessed_image)
File "C:\Users\MainLaptop\AppData\Local\Programs\Python\Python39\lib\site-packages\screen_ocr\_winrt.py", line 15, in run_ocr
return self._executor.submit(lambda: self._run_ocr_sync(image)).result()
File "C:\Users\MainLaptop\AppData\Local\Programs\Python\Python39\lib\concurrent\futures\_base.py", line 445, in result
return self.__get_result()
File "C:\Users\MainLaptop\AppData\Local\Programs\Python\Python39\lib\concurrent\futures\_base.py", line 390, in __get_result
raise self._exception
File "C:\Users\MainLaptop\AppData\Local\Programs\Python\Python39\lib\concurrent\futures\thread.py", line 52, in run
result = self.fn(*self.args, **self.kwargs)
File "C:\Users\MainLaptop\AppData\Local\Programs\Python\Python39\lib\site-packages\screen_ocr\_winrt.py", line 15, in <lambda>
return self._executor.submit(lambda: self._run_ocr_sync(image)).result()
File "C:\Users\MainLaptop\AppData\Local\Programs\Python\Python39\lib\site-packages\screen_ocr\_winrt.py", line 47, in _run_ocr_sync
return asyncio.run(self._run_ocr_async(image))
AttributeError: 'WinRtBackend' object has no attribute '_run_ocr_async'
Edit: Installing from GitHub from zip pip install -e .[winrt]
everything works!
I'm not sure what's going on with pip but installing the package locally works as expected. Given that I've tried this in a completely fresh system this is especially strange. However unless someone else reports the same thing I will consider this issue closed.
I plan to take a closer look when I have time. Probably a bug on my end.
Hmm, I couldn't reproduce it using a venv but on the other hand I was surprised how out of date screen-ocr was. I just pushed new versions of both screen-ocr (so that the module can be run as described in the readme) and gaze-ocr.
Update The underlying issue 'screen_ocr' downloaded twice with 2 different versions.
screen-ocr-0.1.0
is installed notscreen_ocr-0.1.1
despite 0.1.1 downloaded 1st. I suspect this is a PIP issue than the screen-ocr package.See more details https://github.com/wolfmanstout/screen-ocr/issues/3#issuecomment-867081818
pip 21.1.2 from c:\users\mainlaptop\appdata\local\programs\python\python39\lib\site-packages\pip (python 3.9)
Installing from GitHub from zip
pip install -e .[winrt]
everything works as expected.Original Issue
I originally tried from the readme
python -m screen_ocr
No module named screen_ocr.__main__; 'screen_ocr' is a package and cannot be directly executed
I tried executing the contents of
__main__
in an editor and received the following.