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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:28:00+00:00 2026-06-04T05:28:00+00:00

I would like to install some packages into a third-party site-packages directory (beyond the

  • 0

I would like to install some packages into a third-party site-packages directory (beyond the standard system locations). Is there any way to set this up such that .pth files therein are respected?


Background: I’m using OS X, virtualenv, and homebrew. There are a few packages (notably wxPython in my case) that do not install nicely through pip into virtualenv. In these cases, there are homebrew packages that work in their stead. Homebrew creates a third site-packages folder in /usr/local/lib/python2.7. I’d like to simply point to this folder and leave the maintenance of all items there under brew‘s control. It seems, however, that this is not possible.

  • Appending to the path via $PYTHONPATH does not load .pth files. (Should Python 2.6 on OS X deal with multiple easy-install.pth files in $PYTHONPATH?)
  • Python does not allow nesting or recursive use of .pth files. (Nested .pth Files or Loading Extra site-dirs from a Network)
  • The wrapper for virtualenv add2virtualenv adds some extra smarts to the .pth file beyond simply having the directory listed, but I believe it simply reorders the path list.

I’m certainly not the only one interested in this issue. I’d wager a good number of the generic ‘pth files not working’ questions and posts online that I’ve stumbled across are related to this issue. Is there a good solution?

  • 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-04T05:28:01+00:00Added an answer on June 4, 2026 at 5:28 am

    Take a look at the site module. It provides the function addsitedir which should do what you want.

    The easiest way to use this would be to create a file named sitecustomize.py or usercustomize.py and place it in a current PYTHONPATH directory (or any directory that ends up on sys.path) with the following contents:

    import site
    site.addsitedir('/usr/local/lib/python2.7')
    

    When Python is starting an attempt is made to import sitecustomize and then usercustomize, which is why this works. From the site documentation:

    After these path manipulations, an attempt is made to import a module named sitecustomize, which can perform arbitrary site-specific customizations. It is typically created by a system administrator in the site-packages directory. If this import fails with an ImportError exception, it is silently ignored.

    After this, an attempt is made to import a module named usercustomize, which can perform arbitrary user-specific customizations, if ENABLE_USER_SITE is true. This file is intended to be created in the user site-packages directory (see below), which is part of sys.path unless disabled by -s. An ImportError will be silently ignored.

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

Sidebar

Related Questions

I would like to install my setup content only to one specific directory, so
I would like to be able to install all of the NuGet packages in
I would like to install Visual Studio 2008 on a PC with an existing
I would like to install Jobberbase in my website. I have a hosting plan
I would like to install a gem (JSON) on the client side, but only
I would like to make my drivers to install on x64 Windows without the
I would like to know if I can install IIS 7.5 on Windows Server
When someone installs this plugin, I would like a file to be copied into
Our company would like to put some marketing/training content onto USB thumb drives to
How do you get documentation on the packages that you install/uninstall? Every site I

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.