Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4026726
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:00:27+00:00 2026-05-20T11:00:27+00:00

def get_pkgs(): pkgs = [] for importer, modname, ispkg in \ pkgutil.walk_packages(path=None, onerror=lambda x:

  • 0
def get_pkgs():
    pkgs = []
    for importer, modname, ispkg in \
            pkgutil.walk_packages(path=None, onerror=lambda x: None):
    pkgs.append(modname)
    return pkgs

Above code snippet gives me all python packages in distribution. Can someone suggest me a way to get all packages out of these used by a python application ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T11:00:28+00:00Added an answer on May 20, 2026 at 11:00 am

    Snakefood is nice, as already answered by Sven Marnach, but this gives all file dependencies and I’m not sure if it will just tell you what packages are used, versus every single file dependency.

    For packages available in the Python Package Index, you could use virtualenv (and pip, which comes with it) to get a simple list of required/used packages.

    For example, assuming you also have the excellent virtualenvwrapper tools installed (highly recommended), below is a sequence that shows what the package requirements are for pylint:

    $ mkvirtualenv pylint_dep_check --no-site-packages
    New python executable in pylint_dep_check/bin/python
    Installing setuptools............done.
    $ pip freeze   #Note the wsgiref 'bug' where it always shows up
    wsgiref==0.1.2
    $ workon pylint_dep_check
    (pylint_dep_check) $ pip install pylint
    (... snipped lengthy install text ...)
    (pylint_dep_check) $ pip freeze
    logilab-astng==0.21.1
    logilab-common==0.55.0
    pylint==0.23.0
    unittest2==0.5.1
    wsgiref==0.1.2
    

    Noe the all-important use of the --no-site-packages virtualenv creation option which (surprise!) ensures that your virtualenv is completely fresh and has none of the site-packages from your distribution installed. This way it is clear what is needed for the app you installed.

    If this is an application that you have developed, a nice way to keep track of your dependencies (and an excellent/clean way to work) is to set up the application in a clean virtualenv (created using the --no-site-packages option again) and then again use pip freeze to figure out what packages you’ve installed to make it work.

    The ability to start a “fresh” python installation with the --no-site-packages option is extremely useful. I do it for all applications and to test out packages I’m interested in without cluttering my workspace(s).

    If you aren’t using virtualenv and pip yet, get on it already. Here is a good introduction:
    http://mathematism.com/2009/07/30/presentation-pip-and-virtualenv/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say we have a module m : var = None def get_var(): return
As an example: def get_booking(f=None): print "Calling get_booking Decorator" def wrapper(request, **kwargs): booking =
I added a get_absolute_url function to one of my models. def get_absolute_url(self): return '/foo/bar'
To illustrate the question check the following code: class MyDescriptor(object): def __get__(self, obj, type=None):
I am having the below code. import xml.dom.minidom def get_a_document(name): return xml.dom.minidom.parse(name) doc =
def self.get(server) return unless server server = server.to_s if klass = @handlers[server] obj =
class A(): def __init__(self): self.__var = 5 def get_var(self): return self.__var def set_var(self, value):
How can I achieve such job: def get_foo(someobject, foostring): return someobject.foostring IE: if I
This is what I have so far: def get_concrete_name_of_class(klass): Given a class return the
I'd like to do something like: def get_foo(): return self._foo or self._foo = Bar()

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.