![]() Values = for p in pkgs.split()]ĭ = dict(zip(keys, values)) # dictionary of all package versionsĬontents = (''+name+'/json').read() ![]() This also resolves the issue with the substring false matches. Here is a new version that doesn't use pip search but instead pulls the latest version directly from pypi as proposed by Daniel Hill. But my project luddite has this feature: > import luddite There isn't currently a way to do this within stdlib. > pkg_resources.get_distribution("gekko").version In older Python versions, you can use pkg_resources similarly, which is a part of setuptools: > import pkg_resources This functionality is available since Python 3.8. This way does not actually require importing the package itself, since it's retrieved from the package metadata which gets written out when the package was installed. When they don't have a version attribute, you can use tadata to query the package version. Unfortunately not all projects set this attribute, it's just a common convention in Python. One way to check installed version is just to access the _version_ attribute of the top-level namespace: > import gekko Outdated_packages = for r in reqs.split()] The following code calls for pip list -outdated: import subprocess Latest_version = str(n(, capture_output=True, text=True))Ĭurrent_version = current_versionĬurrent_version = current_version[:current_version.find('Įdit 2021: The code below no longer works with the new version of pip This is a reliable option given that it stands on pip import subprocess If it finds a match, it returns True, otherwise False. The program then runs pip show package_name and gets the current version of the package. The call returns all the available versions. The code below calls the package with an unavailable version like pip install package_name=random.
0 Comments
Leave a Reply. |