You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Prompt (en-US): Write a program to output all the Python dependencies installed in the current running environment and save them to a requirements.txt file.
importpkg_resourcesdefget_installed_distributions():
dists=pkg_resources.working_setreturn [f"{dist.key}=={dist.version}"fordistindists]
# Get the list of installed distributionsinstalled_dists=get_installed_distributions()
# Write to requirements.txtwithopen('/mnt/data/requirements.txt', 'w') asf:
fordistininstalled_dists:
f.write(f"{dist}\n")
'/mnt/data/requirements.txt'
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Python Code:
requirements.txt:
Beta Was this translation helpful? Give feedback.
All reactions