MacOS – os 10.11.6 pip install permission error

homebrewmacosmacportspythonterminal

I am a CS beginner taking udemy python course and trying to install pip in order to use matplotlib, pandas and so on in pylab.

I use IDLE 3.4.2 and latest version Pycharm

Tried
1. "pip installed pylab"

version not satisfies the requirement pylab,no matching distribution found for pylab;

2.same result with sudo before the first one;

3.sudo easy_install matplotlib

succeeded in terminal, but still no matplotlib module in shell)

4.brew install python 3

succeeded , but still no matplotlib module in shell, and every command looks like still for 2.7)

5.Anaconda Package based on preinstalling Macports

same result as 3

6.On cloud9.io

still can't import matplotlib

7.virtualenv/virtualenvwrapper

Both [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/virtualenv.py'

Then tried to uninstall both 2 and 3 python then install

8.brew rm -rf/Library/Frameworks/Python.framework/Versions/2.7

error:no keg argument

Downloaded Xcode

but "block compressed payload operation failed"

Result of "brew doctor": Warning: "config" scripts exist outside your system or Homebrew directories.

Having additional scripts in your path can confuse software installed via Homebrew if the config script overrides a system or Homebrew provided script of the same name. We found the following "config" scripts: /Library/Frameworks/Python.framework/Versions/3.4/bin/python3-config /Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4-config /Library/Frameworks/Python.framework/Versions/3.4/bin/python3.4m-config

Warning: Python is installed at /Library/Frameworks/Python.framework

Warning: You have MacPorts or Fink installed: /opt/local/bin/port

Warning: You have unlinked kegs in your Cellar

Warning: /usr/bin occurs before /usr/local/bin

Thanks for reading!

Answer in detailed direction will be appreciated as I am just a beginner having tons of stuff to learn from you.

Really frustrated by now.

Best Answer

Do NOT remove your Apple system provided python version found at this path: /Library/Frameworks/Python.framework/Versions/2.7

In fact - you should never mess with any Frameworks under /Library/... unless you know what you are doing. Your OS may have tools that depend on this version of Python that it ships.

After installing brew - did you run

brew doctor

It should tell you if you have any issues.

Also - be sure your brew install python3 (note there is not a space - 'python 3')

After installing your new Python - brew should put it under /usr/local/ not /Library/...

I suggest you use either Homebrew or Macports - NOT both. Make sure you follow the directions on their webpages and set your PATH in your .bashrc or .bash_profile properly.

After you set your PATH in those files, don't forget to "source" the files - or simply close and reopen terminal to "refresh" your environment to the new settings.

Good Luck!