简体   繁体   中英

Check pytesseract version using python

Is there a way to check pytesseract version in python?
According to PyPi documentation of pytesseract, there is a built-in function get_tesseract_version to get pytesseract version. But when I run it in python, I get the following:

>>> import pytesseract
>>> pytesseract.get_tesseract_version
<function get_tesseract_version at 0x7f4b9edd4598>
>>> print(pytesseract.get_tesseract_version)
<function get_tesseract_version at 0x7f4b9edd4598>

I know that I can get pytesseract version using pip freeze , but I want to get it using python. Is that possible?

You need to call the function – pytesseract.get_tesseract_version() – but that will get you the underlying Tesseract version, not the version of pytesseract in use.

Since pytesseract doesn't unfortunately expose the standard __version__ variable, you can use the pkg_resources API to introspect the current package environment:

>>> import pkg_resources
>>> pkg_resources.working_set.by_key['pytesseract'].version
'0.3.0'

Just add the function parenthesis and you should get the output:

pytesseract.get_tesseract_version() 
5.0.0-alpha.20200328

If you are working with pip, simply type the following command inside your environment:

pip freeze

All installed packages (in that environment) and their corresponding versions will be listed:)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM