0

I set PYTHONPATH variable on my Apple laptop a while ago. I have checked /private/etc/profile config file. It is not there. Where else I could find it?

What other config file could be used to set the PYTHONPATH variable on OS X?

5
  • Maybe try whereis python in your console? Commented Sep 24, 2016 at 19:30
  • I am looking for the config file where PYTHONPATH environment variable is set. Commented Sep 24, 2016 at 19:31
  • 1
    I might have a look at your .bashrc and/or your .bash_profile where the export PATH might be set up manually. In addition, you can check the path of Python by using which python. Commented Sep 24, 2016 at 19:32
  • unix.stackexchange.com/questions/813/… Commented Sep 24, 2016 at 19:37
  • What shell are you using? Commented Sep 24, 2016 at 20:41

1 Answer 1

1

There are several config files that can be used to set PYTHONPATH in OS X:

The first is profile file which is located in hidden /private/etc/ folder:

/private/etc/profile

You can use the following syntax to set the variable there:

export MY_CUSTOM_ENV_VARIABLE="/Applications/MyApp/bin"

Other config files are .cshrc, .bashrc and . bash_profile which (thanks albert for your info) are located in user's home directory and based on your OS X might or might not be there:

/Users/username/.cshrc
/Users/username/.bashrc
/Users/username/.bash_profile

To set the environment variable in .cshrc file use the syntax below:

setenv MY_CUSTOM_ENV_VARIABLE /Applications/MyApp/bin

To set the environment variable using .bash_profile file use this syntax:

export MY_CUSTOM_ENV_VARIABLE=/Applications/MyApp/bin:$MY_CUSTOM_ENV_VARIABLE

In my case PYTHONPATH variable was set in .bash_profile file. And it was set with the following syntax:

export PYTHONPATH=/Users/myModules:$PYTHONPATH
Sign up to request clarification or add additional context in comments.

Comments

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.