How to reset System Variable PATH after tesseract

2019-07-26 21:25发布

问题:

I downloaded and installed tesseract-ocr-setup-3.05.00dev.exe from https://github.com/UB-Mannheim/tesseract/wiki and ticked the Add to Path and Set TESSDATA_PREFIX variable upon installation.

It used to be that my System Path consisted of many things including Python, Node, Npm, etc. Now, it is just a single item of Tesseract (see image)

How can I get back my System Path Variables?

回答1:

Starting from Tesseract 3.05.00 the Add to Path checkbox was removed, as it caused problems. UB-Mannhaim documentation:

Old versions of the installer had an option to add Tesseract to the PATH environment variable. That option was disabled by default. If it was enabled and PATH was very long, it could happen that the new PATH was empty. We suggest not to use that option and disabled it in our latest version.

Following the UB-Mannhaim recommendation, instead of adding PATH to system variables you can always consider setting a local variable in your code.

Example from pytesseract documentation:

# If you don't have tesseract executable in your PATH, include the following:
pytesseract.pytesseract.tesseract_cmd = r'<full_path_to_your_tesseract_executable>'
# Example tesseract_cmd = r'C:\Program Files (x86)\Tesseract-OCR\tesseract'

Another example for pyocr:

pyocr.tesseract.TESSERACT_CMD = r'<full_path_to_your_tesseract_executable>'


回答2:

https://superuser.com/a/265575

Restoring System PATH: Open Regedit

  1. List item 2.Select HKEY_LOCAL_MACHINE
  2. File->Load Hive
  3. Navigate to your C:\Windows\System32\config\RegBack, click the little button to the right of "Open" for "Show Previous Versions": enter image description here**
  4. Select appropriate revision
  5. Select SYSTEM.OLD***
  6. Give it a name (e.g. "Old")
  7. Navigate to HKEY_LOCAL_MACHINE\"Old"\ControlSet001\Control\Session Manager\Environment
  8. Open the PATH value and copy it to clipboard, then paste into system environment variables screen.

** I had to use shadowexplorer to export my RegBack first, because it was "currently in use"
*** I just selected SYSTEM