Skip to main content

Summary

Locate a python object (package, module, function, class …) source file.

Usage

pywhereis [-v] [-s] dotted_name...

CMD line Examples

  • The pywhereis script accept a package, module, function or a class

    $ pywhereis shlex
    shlex: /usr/lib/python2.7/shlex.py
    $ pywhereis os.path.abspath
    os.path.abspath: /usr/lib/python2.7/posixpath.py  337
  • You can pass more than one dotted-name to it

    $ pywhereis shlex inspect.ismodule
    shlex: /usr/lib/python2.7/shlex.py
    inspect.ismodule: /usr/lib/python2.7/inspect.py  51
  • If the name is a function, class or method the result will contain the line number where the object is defined

    $ pywhereis unittest.TestCase.assertEqual
    unittest.TestCase.assertEqual: /usr/lib/python2.7/unittest.py  344
  • It will fail localizing object that are not pure python

    $ pywhereis.py sys
    sys:
  • For more info about why the localization fail you can use the verbose mode

    $ pywhereis -v sys
    sys: Error: <module 'sys' (built-in)> is not pure python.
  • If it’s run with -s, –site-packages option the script will check first in site-packages instead of the default which is to check in the current dir first

    $ cd ~ ; touch os.py
    $ pywhereis os
    os: /home/mouad/os.py
    $ pywhereis -s os
    os: /usr/lib/python2.7/os.py

    Note: Option only available for python3.2 and below !

  • For python2.7 and above you can also do

    $ python2.7 -mpywhereis subprocess.Popen
    subprocess.Popen: /usr/local/lib/python2.7/subprocess.py 33

    Note: The above will only work if pywhereis was installed in that python version.

  • Of course you can still search in a different python version by running this script using that python

    $ python3.4 $(which pywhereis) html
    html: /usr/local/lib/python3.4/html/__init__.py

Code Examples

This package come also with a python package whereis that can be used like so

>>> import whereis
>>> whereis.resolve('sys')
<module 'sys' (built-in)>
>>> whereis.locate('os')
'/usr/lib/python2.7/os.py'

CHANGES

0.3

  • Fixing bug _issue#2: https://bitbucket.org/mouad/pywhereis/issue/2, This mean that user can install pywhereis once in any Python version, and use it everywhere i.e. with other python versions or inside virtualenv … , This work for now with only POSIX compliant system.

  • BUGFIX: Fix locating not pure Python modules, bug noticed when trying to locate lxml.etree.XPath.

  • Add support to Python3.4 and Python3.3.

  • Change versioning instead of 0.0.2 now it’s 0.3.

  • Backward incompatibilty change: pywhereis return now the real path instead of symlink.

0.0.2

  • Add support to locating zip archive and eggs modules.

  • Add a new argument -s, –site-packages that enable looking in site-packages directory before current directory.

  • BUGFIX: Fix whereis.resolve to always raise ImportError even if the module that we are searching for is broken (SyntaxError …), the same with whereis.locate.

0.0.1

First release.

Metadata

Release files for pywhereis 0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pywhereis 0.3
File Size Uploaded Provenance
pywhereis-0.3.tar.gz 8.4 kB Without provenance Details

Release files / pywhereis-0.3.tar.gz

Download URL pywhereis-0.3.tar.gz
Size 8.4 kB
Tags Source
SHA-256 checksum
How to use checksums
78ec3d1e46053742fcb0290e2108997cc18ada4e0bb8cb0d927a5919550779f0
BLAKE2b-256 checksum
How to use checksums
51095a199c967a01323ea955f287270d7b8da6ef796229829e7998bf557e1678
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for pywhereis 0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.3 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page