My Terminal has became useless after installing Python


[Re-Titled by Moderator]

MacBook Air 13″, macOS 14.1

Posted on Nov 13, 2023 12:40 AM

Reply
Question marked as Top-ranking reply

Posted on Nov 18, 2023 8:23 PM

Close the Terminal app.


Then use the Finder to show your home user folder. Within the Finder, click the "Go" menu and select "Home".


Now show hidden files within the Finder by pressing the following three keys together to toggle showing hidden files on & off:

Command + Shift + Period


By using those keys you should see some additional files & folders appear in your home user folder. Start by renaming the ".bash_profile" file by adding "--bak" so the file becomes ".bash_profile--bak". If you don't have a ".bash_profile" file, but instead a ".profile" file instead, then rename that file in the same manner.


Now try launching the Terminal app to see if it launches correctly.


If so, then there is some mis-configuration in that file. Post the contents of the file here using the "Code Insertion" tool with the icon "</>". You may need to first paste the contents, then highlight them and press the "Code Insertion" tool. The Code Insertion tool will make reading the file much easier since the file is actually script code.


If renaming that file does not help, then let us know.


Unfortunately with two separate versions of Python installed now, it will be very difficult to clean up now. While we may be able to resolve the immediate Bash profile issue, you may still find other issues that may not become apparent until much later.


You may find it much faster & easier to backup your data to an external drive. Then erase the system & reinstall macOS. Then transfer the data back. Reinstall your third party applications, this time avoiding Homebrew. Then make sure to start some sort of regular backups.....the easiest option would be to use the built-in Time Machine app to manage your backups which would require purchasing an external USB3 drive that is 2x to 3x the size of your boot drive.


FYI, even though you may be learning Python, it is probably a good idea to learn the basics of using the command line as well. Especially if you are going to run commands since you must learn what different commands do and be able to figure out how to understand what various commands & options do. Here is a basic Bash tutorial for macOS (most online tutorials will involve Linux....the basics are generally the same although Linux may have a lot more advanced options available & some Linux only commands).

https://scriptingosx.com/2017/07/first-steps-in-terminal/


9 replies
Question marked as Top-ranking reply

Nov 18, 2023 8:23 PM in response to Ana-Alef

Close the Terminal app.


Then use the Finder to show your home user folder. Within the Finder, click the "Go" menu and select "Home".


Now show hidden files within the Finder by pressing the following three keys together to toggle showing hidden files on & off:

Command + Shift + Period


By using those keys you should see some additional files & folders appear in your home user folder. Start by renaming the ".bash_profile" file by adding "--bak" so the file becomes ".bash_profile--bak". If you don't have a ".bash_profile" file, but instead a ".profile" file instead, then rename that file in the same manner.


Now try launching the Terminal app to see if it launches correctly.


If so, then there is some mis-configuration in that file. Post the contents of the file here using the "Code Insertion" tool with the icon "</>". You may need to first paste the contents, then highlight them and press the "Code Insertion" tool. The Code Insertion tool will make reading the file much easier since the file is actually script code.


If renaming that file does not help, then let us know.


Unfortunately with two separate versions of Python installed now, it will be very difficult to clean up now. While we may be able to resolve the immediate Bash profile issue, you may still find other issues that may not become apparent until much later.


You may find it much faster & easier to backup your data to an external drive. Then erase the system & reinstall macOS. Then transfer the data back. Reinstall your third party applications, this time avoiding Homebrew. Then make sure to start some sort of regular backups.....the easiest option would be to use the built-in Time Machine app to manage your backups which would require purchasing an external USB3 drive that is 2x to 3x the size of your boot drive.


FYI, even though you may be learning Python, it is probably a good idea to learn the basics of using the command line as well. Especially if you are going to run commands since you must learn what different commands do and be able to figure out how to understand what various commands & options do. Here is a basic Bash tutorial for macOS (most online tutorials will involve Linux....the basics are generally the same although Linux may have a lot more advanced options available & some Linux only commands).

https://scriptingosx.com/2017/07/first-steps-in-terminal/


Nov 14, 2023 1:19 PM in response to Ana-Alef

If I had to guess.....you installed Homebrew? If so, is this how you installed Python or did you download Python directly from the developers? These details are critical for assisting you. Obviously some app or apps you installed have made poor modifications to one of your Bash profile files, or perhaps you manually modified one of them yourself. You will need to edit the bash profile file with the issue and comment out the offending line until you can figure out how to fix it, or you need to correct the bad line, or you can temporarily rename the file so it is not used when launching the Terminal or a Bash session.


The Bash profiles are hidden files within your home user folder and could be any or all of the following: .bashrc, .bash_profile, or even .profile (I don't recall what the macOS default is for a clean install and it may depend on the version of macOS as well). The latter two files are more likely to have been modified, so I would start with them first.


FYI, here is where you should be acquiring Python3:

https://www.python.org/downloads/


I hope you made a backup before you started installing and modifying your system. You may need it to fix things.


Nov 20, 2023 6:12 PM in response to Ana-Alef

Ana-Alef wrote:

Thanks a lot. It worked. What should I do now?

If you want to fix the issue(s) with that file, then you would need to post the contents of that file using the Code Insertion tool so we can examine it to locate the problem. However, we believe the easiest & best way forward is to perform a clean install as I mentioned previously and @etresoft has also mentioned since we may be able to fix the issue with .bash_profile, but there sounds like there may be other things which would need fixed as well that may not be apparent at this time. Since you don't have much set up here and very little data involved, now would be the time for the clean install. That should lead to a more stable & reliable system.


After that, can you tell me how can I install Python in the best way? I really need your advice for this too.

Use the link in my earlier post to access the official Python installer. It should install like any other macOS app.


About backup and reinstall the OS, I reinstall it once and nothing was gone.

You need to perform a clean install which begins with erasing the disk, otherwise your data is still on the drive & will be exactly the same as before "reinstall".


What things I should backup? I can backup my necessary data, but I don't have many things on my MacBook nor important things.

Sounds like copying the important files to external media temporarily would be easiest since you don't have too much data at this time.


Once you have performed the clean install and set up the Mac, then start using Time Machine to backup your Mac regularly & frequently.

Back up your Mac with Time Machine - Apple Support


Make sure to always have frequent and regular backups. There are a lot of new ways to permanently lose access to your data on the newer Macs if you don't have good backups.

Nov 20, 2023 5:50 AM in response to Ana-Alef

Ana-Alef wrote:

About backup and reinstall the OS, I reinstall it once and nothing was gone. What things I should backup?
I can backup my necessary data, but I don't have many things on my MacBook nor important things.

Use Time Machine to backup your computer. But you might want to wait until you get everything fixed.


If you don't have many things on your computer right now, then the easiest solution would be to just manually copy those important files to an external hard drive or somewhere on the internet (iCloud maybe?). Then, erase the hard drive entirely and reinstall the operating system.


Then never, ever install Homebrew again. Your experience is typical. I don't understand what's going on with that software. It is incessantly pushed all across the internet. Yet whenever someone comes here with their Terminal environment completely unusable, or basic commands not working with errors that no one has ever seen before, Homebrew is always the reason.

Nov 21, 2023 5:56 PM in response to Ana-Alef

Ana-Alef wrote:

After backing up my data, just in case, in order not to make a mistake again, can you tell me how to clean install?

Here is an Apple article with instructions for an Apple Silicon Mac, but there is a link within that article for an Intel Mac as well (just make sure you erase the system using one of the methods mentioned):

Use Disk Utility to erase a Mac with Apple silicon - Apple Support


Nov 17, 2023 11:35 PM in response to HWTech

I installed python following instruction with Homebrew. And then install from Python website for Python IDLE Shell...


and unfortunately, I have not made a backup...


I don't know what to do at all. I'm not expert user of MacBook and I was just starting learn Python...


Can you help me to fix it?

I don't care if everything on my laptop removes and back to factory version.

Nov 20, 2023 12:23 AM in response to Ana-Alef

Last login: Mon Nov 20 12:01:58 on console


The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT20https://support.apple.com/kb/HT208050.

Thanks a lot. It worked. What should I do now?


and Thank you so much for your advice about learning basic commands.

I really like to learn, but I didn't know where should I start from.

After that, can you tell me how can I install Python in the best way? I really need your advice for this too.


About backup and reinstall the OS, I reinstall it once and nothing was gone. What things I should backup?

I can backup my necessary data, but I don't have many things on my MacBook nor important things.



Nov 21, 2023 5:00 AM in response to HWTech

Thanks a lot.

I have the original Python file and I installed it too!

However it will be erased when I clean install the operating system.

About Homebrew, I absolutely don't try it again. In fact I wanted to ignore it when articles were talking about it, but after many suggest for doing this, I finally used it.


After backing up my data, just in case, in order not to make a mistake again, can you tell me how to clean install?

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

My Terminal has became useless after installing Python

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.