0

I am using MACOS 10.12.6

I was trying to uninstall python to reinstall it, and I foolishly typed these commands into my terminals.

sudo rm -rf /Users/<myusername>/anaconda2/lib/python2.7
sudo rm -rf /Users/<myusername>/anaconda2/lib/python27.zip
sudo rm -rf /Users/<myusername>/anaconda2/lib/python2.7/plat-darwin
sudo rm -rf /Users/<myusername>/anaconda2/lib/plat-mac
sudo rm -rf /Users/<myusername>/anaconda2/lib/plat-mac/lib-scriptpackages

now my Python won't work. I get these errors:

>Could not find platform independent libraries <prefix>
>Could not find platform dependent libraries <exec_prefix>
>Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]

And when I try to run python I get things such as

>ModuleNotFoundError: No module named 'pandas'

I currently cannot do anything which requires python

I came to understand much later that what I did was deleting an important part of python files from my computer.
Is there any way I can reinstall python or is formatting my computer the only option if I want to use Python on this computer?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
  • 3
    Using `sudo` wiht `rm` and `-rf` ... you should have read the manual before using this. You need to reinstall python: https://docs.python.org/3/using/mac.html - and https://stackoverflow.com/questions/34303294/how-to-fix-broken-python-2-7-11-after-osx-updates might alleviate your problems. – Patrick Artner Jun 01 '18 at 09:53

2 Answers2

1

Since you used Anconda on your mac you should be able to just reinstall python 2.7. If you still have the install package: Anaconda2-5.2.0-MacOSX-x86_64.pkg, just double click that and follow directions. If you don't have this package, download it from here and when the package downloads completely double-click it.

Natsfan
  • 4,093
  • 3
  • 22
  • 29
0

You only deleted Anaconda, not the System Python.

Therefore, you probably only need to edit your PATH variable to remove references to those folders.

Check your ~/.bashrc

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245