Where is the .profile file on mac?
Asked Answered
R

5

24

I have a MacBook Pro 13` inch (without touch bar) and it is running mac os sierra. I have installed Xcode, command line tools and homebrew. Now I want to install python 3 and make it a default interpreter when calling it from the terminal. I have found this guide http://docs.python-guide.org/en/latest/starting/install3/osx/ and I get confused when they say I should add the path to the ~./profile but I don't know where to find the file. Can somebody help with step by step guide on how to create it if it not there?

Thanks

Riparian answered 24/4, 2018 at 9:24 Comment(2)
It's probably ~/.bash_profile or ~/.bashrcBloody
where is this file. i am trying to instal python3Illuminance
M
28

The file you are looking for depends on your shell, so if you are using bash, which is the default shell on Mac systems, it will be either ~/.bash_profile, or ~/.bashrc depending on whether you are in a login shell or non-login shell respectively.

Mac Terminal runs a login shell every time a new terminal window is open, and it calls .bash_profile, so you should use ~/.bash_profile.

Munday answered 24/4, 2018 at 9:28 Comment(5)
where is this file. i am trying to instal python3Illuminance
@AwaisFayyaz it is under you home folderMunday
the ~ in ~/.bash_profile represents your home path. so cd ~ would navigate you to your home directory.Heckelphone
Downvote. The OP asked "Where" the file was located. "~" is not a path.A1
@A1 ~ is a path, the path of the home directoryMunday
L
29

I felt to add something here that ate a lot of my time when I had a similar issue.

Many a times the .profile or the .bash_profile (in case of bash shell) is not present. This is typically when you have freshly installed the OS or when you're on a new machine. This gets confusing as one may think if the installation wasn't correct etc. Nothing to worry about. If you don't find these files then simply create it new using vi or whatever means (GUI) and you're good to go. Having a shell doesn't mean you have these files too and you have to create it yourself if you're the first one to use it.

Langsdon answered 10/8, 2019 at 14:16 Comment(2)
I have tried creating .bash_profile and then I loaded using 'source', and it didn't seem to work for me. Since ssh is the default shell on MAC, I ended up creating .zshrc file and then loaded it using source, and it worked for me.Acrophobia
This answer is not correct. The OP asked where the .profile is located on the Mac. Just saying "create one" doesn't answer this question.A1
M
28

The file you are looking for depends on your shell, so if you are using bash, which is the default shell on Mac systems, it will be either ~/.bash_profile, or ~/.bashrc depending on whether you are in a login shell or non-login shell respectively.

Mac Terminal runs a login shell every time a new terminal window is open, and it calls .bash_profile, so you should use ~/.bash_profile.

Munday answered 24/4, 2018 at 9:28 Comment(5)
where is this file. i am trying to instal python3Illuminance
@AwaisFayyaz it is under you home folderMunday
the ~ in ~/.bash_profile represents your home path. so cd ~ would navigate you to your home directory.Heckelphone
Downvote. The OP asked "Where" the file was located. "~" is not a path.A1
@A1 ~ is a path, the path of the home directoryMunday
E
22

On Mac, zsh is the default shell. You can check this by running

echo $SHELL

If so, you can check for ~/.zshrc if not you can create one and add required commands, alias which need to run during the terminal startup.

Then you can run

source ~/.zshrc

This will be executed every time the terminal is opened.

Earphone answered 12/7, 2021 at 16:56 Comment(0)
F
4

It could be that you are not running bash (rather an extended version like zsh, ksh, etc)

If you are running bash shell, then you should be able to see ~/.bash_profile, or ~/.bashrc or ~/.profile.

Incase of zsh shell, you would see .zprofile or .zshrc

You can check what shell you have by echo $SHELL

Fanchette answered 13/9, 2021 at 0:24 Comment(0)
T
3

After you install "Brew", there is a prompt in the terminal that says: "Next Steps:"

Follow those steps!

Tontine answered 16/2, 2023 at 20:10 Comment(1)
and might need to restart terminal afterwards.Allard

© 2022 - 2025 — McMap. All rights reserved.