0

I want to know if it is possible to add the path to a directory to the environment variables permanently using python. I have seen other questions that relate to mine but the answers there only add the path temporarily,I want to know if there's a way to add it permanently

5
  • 1
    unix.stackexchange.com/questions/117467/… This is what you are looking for? Commented Aug 23, 2016 at 8:46
  • 1
    Possible duplicate of How to set environment variables in Python Commented Aug 23, 2016 at 8:48
  • No, I have a python program that needs marionette driver to run and the path to the driver has to be added to the env variables for it to run. So I want the program to automatically add the path to env variables if it isn't there already. Commented Aug 23, 2016 at 8:50
  • Do you mean PYTHONPATH (to find python modules) or PATH (for executing shell commands)? Commented Aug 23, 2016 at 9:04
  • @Levi PATH for executing shell commands Commented Aug 23, 2016 at 9:21

1 Answer 1

1

While using bash add this ~/.bashrc export PYTHONPATH="${PYTHONPATH}:/Home/dev/path

Make sure the directory you point to has at the topmost init.py file in your directory structure

Sign up to request clarification or add additional context in comments.

2 Comments

plus1 but just to clarify you need to restart or source ~/.bashrc so it will actually take effect
I need to add to PATH not PYTHONPATH

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.