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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:28:02+00:00 2026-06-05T16:28:02+00:00

When a non built-in module is imported, the interpreter searches in the locations given

  • 0

When a non built-in module is imported, the interpreter searches in the locations given by sys.path. sys.path is initialized from these locations (http://docs.python.org/library/sys.html#sys.path):

  1. the directory containing the input script (or the current directory)
  2. PYTHONPATH
  3. the installation-dependent default

While the first two sources are straight-forward, can anyone explain how the third one works, and what possibilities there are for influencing it?

Although I would be interested in a general solution, my specific issues are:

  • I have installed the Enthought distribution 7.2 32-bit, and then Scipy-Superpack. Now enthought python tries to import numpy from /Library/Python/2.7/, which is where superpack installed them, instead of from the enthought site-packages.
  • a wxPython application created with py2app -A does not have the same sys.path as when starting the application with python start_app.py.
  • 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-06-05T16:28:05+00:00Added an answer on June 5, 2026 at 4:28 pm

    The basis of the third source is set at compile time (or configure time, more precisely), depending on the platform. It is then expanded and added to at run-time via .pth files, etc. (which is something you can do once the Python executable is compiled to influence that third source).

    This page of the Python documentation has all the information on how .pth files work, and also more information on how sys.path is constructed from build-time settings, etc. http://docs.python.org/library/site.html

    I’m not sure why you want to influence that third source specifically though, when you can influence the whole sys.path. Anyhow, the three ways of influencing sys.path (without recompiling Python or patching the source code) are:

    1. Via the PYTHONPATH environment variable.
    2. By creating .pth files and dropping them where Python scans for packages. (See the link earlier for details.)
    3. Programmatically, by importing sys and then appending or prepending to sys.path

      import sys
      sys.path.insert(0, '/this/path/will/be/considered/first')
      

    Hopefully one of these three ways should help you do what you want.

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

Sidebar

Related Questions

TL;DR: Adding any non-built-in functions to Array.prototype AND Function.prototype will cause the IE8 native
My model is built on non-numerical ID's (36-char. GUID to be specific). The problem
Custom non-fatal exception derive from which class in asp.net 3.5?
The IIS URL Rewrite Module ships with 3 built-in functions : * ToLower -
In http://windows.php.net/downloads I couldn't find any x64 built for download. Further I have to
I'm using Python's built-in unittest module and I want to write a few tests
My module contains some non java files along the java source files. When the
I want to build a 2 dimensional (non ragged at this point) object array.
I'm planning to take a non-GUI Linux distro (no Gnome, KDE, etc) and build
Non inline function defined in header file with guards #if !defined(HEADER_RANDOM_H) #define HEADER_RANDOM_H void

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.