-
Notifications
You must be signed in to change notification settings - Fork 720
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
Support for passing custom environment variables to subprocess #429
Comments
One way to workaround that is to set the environment beforehand, because if I recall correctly, forking inherits the env from the parent process. Ofcourse, the downside is that you are setting the env vars once and it pollutes the current env forever until you change them again. |
As you already mentioned, your approach would make this setting permanent for the whole program. I could write a context manager for temporarily changing the value, but this is quite an overhead. For now, I settled on monkey patching the pytesseract environment, but this is just an ugly hack as well: import copy
import os
from pytesseract import pytesseract
path = 'path/to/file.jpg'
pytesseract.environ = copy.deepcopy(os.environ)
pytesseract.environ['OMP_THREAD_LIMIT'] = '1'
print(pytesseract.image_to_data(path, output_type='data.frame')) |
I guess that you want to dynamically change the environment variables. The python docs refer to I am not sure, but maybe |
I would like to pass my own environment variables to the subprocess, for example to set OMP_THREAD_LIMIT. This custom value should be limited to a specific scope, as other parts of my program should not be affected by this.
Judging from the code, this is not possible for now.
The text was updated successfully, but these errors were encountered: