KnowledgeBoat Logo

Computer Science

In which order Python looks for the function/module names used by you.

Python Libraries

4 Likes

Answer

Python looks for the module names in the below order :

  1. Built-in Modules — Python first looks for the module in the built-in modules that are part of the Python standard library.
  2. Directories in sys.path — If the module is not found in the built-in modules, Python searches for it in the directories listed in the sys.path variable. The directories in sys.path typically include the current directory, directories specified by the PYTHON PATH environment variable, and other standard locations such as the site-packages directory.
  3. Current Directory — Python also looks for the module in the current directory where the Python script or interactive session is running.

Answered By

3 Likes


Related Questions