Home > Software design >  What is the pyodbc version?
What is the pyodbc version?

Time:09-09

I can establish whether suds is installed by following these instructions:

checking suds version in python

i.e. by running the following commands inside the Python console:

>>>> import suds
>>>> print suds.__version__
0.4.1

I now want to establish if pyodbc is installed. I have tried this:

>>>> import pyodbc
>>>> print pyodbc.__version__

The import produces no error. However, when I attempt to print the version; I see this:

AttributeError: 'module' object has no attribute 'version'

Is there anything else I can try. PIP does not appear to be installed.

CodePudding user response:

The attribute name is just version:

print(pyodbc.version)

Could have found this out using dir:

import pyodbc

print(dir(pyodbc))

outputs

[..., 'version']

CodePudding user response:

@DeepSpace gives the correct answer above for this package or others that include specific versions.

If you've got other packages which don't have version numbers in the code itself, you can try printing pyodbc.__file__. Then navigate to that directory.

Then do an ls (or dir on Windows).

You should see several files / directories containing pyodbc. The name of one of those directories will probably include the version number, e.g. pyodbc-4.0.34.dist-info for a relatively recent installation implies version 4.0.34.

You can also read the METADATA file (in the pyodbc-4.0.34.dist-info directory) and look for the line which explicitly labels the Version, e.g. Version: 4.0.34.

  • Related