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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:54:28+00:00 2026-05-26T13:54:28+00:00

EDIT: Works for root, sudo is the problem. Read below. I have a directory

  • 0

EDIT: Works for root, sudo is the problem. Read below.

I have a directory with my own libraries, e.g. my Python libraries are located at /home/name/lib/py.
I’ve added this directory to Python’s PATH for all users (including root) by adding the following line to /etc/bash.bashrc:

export PYTHONPATH=$PYTHONPATH:/home/name/lib/py

It works for all users (including root). But it doesn’t work for sudo. Is there any way I can make sudo use /etc/bash.bashrc?

EDIT: More information:

I’ve added PYTHONPATH to sudoers file like so: Defaults env_keep += "HOME PYTHONPATH". It sitll doesn’t work.

env | grep PYTHON:
    PYTHONDONTWRITEBYTECODE=1
    PYTHONPATH=/home/name/lib/py

sudo env | grep PYTHON:
    PYTHONDONTWRITEBYTECODE=1

sudo echo $PYTHONPATH:
    /home/name/lib/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-05-26T13:54:29+00:00Added an answer on May 26, 2026 at 1:54 pm

    The fix in my case was to remove Defaults !env_reset from sudoers.

    But, I had to keep Defaults env_keep += "PYTHONPATH" in sudoers.
    I’ve actually added Defaults env_reset (which resets environment variables), but it still works because of env_keep.

    It seems that env_keep and !env_reset conflict with eachother, but that’s just a guess.


    So, the whole process:

    1. add export PYTHONPATH=/your/custom/path to ~/.bashrc or /etc/bash.bashrc
    2. add PYTHONPATH to Defaults env_keep += "ENV1 ENV2 ..." in sudoers file
    3. remove Defaults !env_reset from sudoers file if present
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider I have a directory called root that has two directories: x and y
I have some nice, working edit-undo functionality in my winforms application. It works using
This works: Entities.WorkOrderSet.Where(MyCustomMethod); This does not: Entities.WorkOrderSet.Where(o => MyCustomMethod(o)); ( [Edit] Even without new
I use edit-in-place plugin: http://arashkarimzadeh.com/jquery/7-editable-jquery-plugin.html I't works Great! I just need something to check
**EDIT: There are several options below that would work. Please vote/comment according to your
EDIT: Scotty2012 and David Morton's answers don't work for me so I have put
I've got a python program which runs via crontab and that works perfectly. However,
I have a stored procedure that works in the mysql> terminal, but when I
I'm an XML newbie and I have an XML document (which I can't edit
Edit: I've solved the problem myself. If anyone has a better or more elegant

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.