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 6147439
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:06:33+00:00 2026-05-23T19:06:33+00:00

I thought that the sys.path was a complete list of all search paths for

  • 0

I thought that the sys.path was a complete list of all search paths for Python modules.

However, on my Ubuntu machine, ‘/usr/local/lib/python2.6/dist-packages/’ is where almost all my modules are and that path is not in sys.path. And I can still import any module on that path.

EDIT, NOT TRUE: Even if I set the sys.path to the empty list, I can still import from that path.

Where does this implicit knowledge of the dist-packages path come from? And are there any other paths in this implicit group of search paths, or whatever it is?

EDIT: It seems like the second part of my post is not true. Indeed, “sys.path = []”, will mean that I can not import anything, not even from my current working directory. My apologies.

  • 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-23T19:06:33+00:00Added an answer on May 23, 2026 at 7:06 pm

    Note the mention of an installation-dependent default in the following:

    6.1.2. The Module Search Path

    When a module named spam is imported, the interpreter searches for a
    file named spam.py in the directory containing the input script and
    then in the list of directories specified by the environment variable
    PYTHONPATH. This has the same syntax as the shell variable PATH, that
    is, a list of directory names. When PYTHONPATH is not set, or when the
    file is not found there, the search continues in an
    installation-dependent default path; on Unix, this is usually
    .:/usr/local/lib/python.

    Actually, modules are searched in the list of directories given by the
    variable sys.path which is initialized from the directory containing
    the input script (or the current directory), PYTHONPATH and the
    installation-dependent default
    . This allows Python programs that know
    what they’re doing to modify or replace the module search path. Note
    that because the directory containing the script being run is on the
    search path, it is important that the script not have the same name as
    a standard module, or Python will attempt to load the script as a
    module when that module is imported. This will generally be an error.
    See section Standard Modules for more information.

    edit On my Ubuntu box, /usr/local/lib/python2.6/dist-packages is present in sys.path. If I clear sys.path and then try to import a module from the above directory, that no longer works. This suggests that the interpreter has no implicit knowledge of that directory and finds it via sys.path.

    edit When you conduct your experiments, make sure that you modify sys.path right at the start of your Python session. If you import X, then clear sys.path, and then import X again, the latter will not fail even though X is no longer on sys.path.

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

Sidebar

Related Questions

I thought import sys sys.path.append(/home/me/mydir) is appending a dir to my pythonpath if I
I'm using Ubuntu 10, python 2.6.5 I'm following this tutorial: http://www.djangobook.com/en/2.0/chapter02 I followed all
I thought that would have been simple but it is not working. I can,
I thought that there was some way in .net 3.0 to give an array
I thought that it would be fun to present some classic CS problems and
I thought that a delegate instance was interchangeable with a function instance. Take the
I thought that by default my Regex would exhibit the greedy behavior that I
I thought that calling BeginInvoke more than once on the same delegate instance would
I thought that this was easier… I have a asp:hyperlink control, with target=_blank ,
I thought that layout is just a widget that keeps more widgets inside. But

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.