4 examples of 'python print version' in Python

Every line of 'python print version' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
32def python_version() -> None:
33 """
34 Check that the Python version is supported
35 """
36 py_version = sys.version.split()[0]
37 if py_version < "3.5":
38 print(error_message(), "Unsupported Python version")
39 sys.exit(1)
46def version(verbose=False):
47 """
48 Returns the version string for this BE installation. If
49 verbose==True, the string will include extra lines with more
50 detail (e.g. last committer's name, etc.).
51 """
52 if "_VERSION" in globals():
53 string = _VERSION
54 else:
55 string = version_info['revision']
56 if verbose == True:
57 info = copy.copy(version_info)
58 info['storage'] = libbe.storage.STORAGE_VERSION
59 string += ("\n"
60 "revision: %(revision)s\n"
61 "date: %(date)s\n"
62 "committer: %(committer)s\n"
63 "storage version: %(storage)s"
64 % info)
65 return string
102def print_py_pkg_ver(pkgname, modulename=None):
103 if modulename is None:
104 modulename = pkgname
105 print
106 try:
107 import pkg_resources
108 out = str(pkg_resources.require(pkgname))
109 print pkgname + ': ' + foldlines(out)
110 except (ImportError, EnvironmentError):
111 sys.stderr.write("\nGot exception using 'pkg_resources' to get the version of %s. Exception follows.\n" % (pkgname,))
112 traceback.print_exc(file=sys.stderr)
113 sys.stderr.flush()
114 pass
115 except pkg_resources.DistributionNotFound:
116 print pkgname + ': DistributionNotFound'
117 pass
118 try:
119 __import__(modulename)
120 except ImportError:
121 pass
122 else:
123 modobj = sys.modules.get(modulename)
124 print pkgname + ' module: ' + str(modobj)
125 try:
126 print pkgname + ' __version__: ' + str(modobj.__version__)
127 except AttributeError:
128 pass
27def show_version():
28 print('Mamba Sql Tools v{}'.format(version.short()))
29 print('{}'.format(copyright.copyright))

Related snippets