5

I am trying to install jupyter on mac, I understand that the mac comes with python version installed But i also installed brew and installed python through brew.

When i check python location i get:
which python /usr/bin/python

When i check pip location i get:
which pip
/usr/local/bin/pip

When i try to install jupyter:
pip install install after a long installation it tried to remove python package that it want's to upgrade And fails: enter image description here On trying to uninstall dateutil.
I think its the mac packages. I tried with sudo, no change.
As far as i can understand it because the files are immutable.
Tried to remove the immutable with:
chflags uchg.
No change.

I also tried to work with virtual env, using:
sudo pip install virtualenvwrapper.
But that pip tries to uninstall another python folder.
Any suggestions?
Thanks


UPDATE:

The brew seems to create links from python2. to python2
And the same for python3.
I tried to create the link myself, It worked and i was manage to install the package i wanted. But its not a good solution,
The all point of brew is to manage this things for me, next time i will upgrade python it will break. Any suggestions why? could it be because the brew installed two python version on my laptop?


RESOLVED:

Found the answer, thanks to @tdube question i went and looked what brew guys did to python and found this thread from Jan 17.
I turns out that they changed the behavior or installing python.
No you don't have simply python any more.
You have python2 and python3.
No more simply pip, now you have pip2 and pip3.

That is a major change from the default behavior of how people use python Especially that mac comes with a default python

so now you have python that is /usr/bin/python python2 that is /usr/local/bin/python2 python3 that is /usr/local/bin/python3

this is the fix, the brew guys suggest ( you can see it when running brew info python ):

==> Caveats
This formula installs a python2 executable to /usr/local/bin.
If you wish to have this formula's python executable in your PATH then add
the following to ~/.zshrc:
  export PATH="/usr/local/opt/python/libexec/bin:$PATH"

Pip and setuptools have been installed. To update them
  pip2 install --upgrade pip setuptools

You can install Python packages with
  pip2 install <package>

They will install into the site-package directory
  /usr/local/lib/python2.7/site-packages

See: http://docs.brew.sh/Homebrew-and-Python.html

You can read about it in this thread:

ohad edelstain
  • 1,425
  • 2
  • 14
  • 22

1 Answers1

0

The Python that comes "pre-installed" on Mac is located in /usr/bin/python. I think you need to change the order of the entries in your PATH environment variable as noted here (python homebrew by default). Which file your PATH is set in depends on which shell you are using.

tdube
  • 2,453
  • 2
  • 16
  • 25
  • I followed what they said there but it didn't work, the brew linked python2. to python2, and the same for python3, maybe the problem is that it installed both python? – ohad edelstain Aug 08 '17 at 05:42
  • What does `env | egrep "^(SHELL|PATH)"` return for you? – tdube Aug 08 '17 at 13:39
  • `SHELL=/bin/zsh PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/Cellar/maven/3.5.0/libexec/bin` – ohad edelstain Aug 08 '17 at 14:46
  • 1
    @ohadedelstain Can you restart your shell/terminal and then try again and see if it works now? – tdube Aug 08 '17 at 16:40
  • @ohadedelstain Also, please confirm the path to `/usr/local/bin/python` exists. – tdube Aug 08 '17 at 18:07
  • no there is not /usr/local/bin/python the brew for some reason only created: /usr/local/bin/python2 -> ../Cellar/python/2.7.13_1/bin/python2 and /usr/local/bin/python3 -> ../Cellar/python3/3.6.2/bin/python3 – ohad edelstain Aug 09 '17 at 05:43
  • @ohadedelstain You should be able to invoke those then by calling either `python2` or `python3` from the command line. If you want to be able to invoke one of those brew version of Python (version 2 or 3; your choice) by just typing `python`, you can add a symlink for `python` to `/usr/local/bin/`. For example, to make `python` point to `python2` on the command line type `sudo ln -s /usr/local/bin/python2 /usr/local/bin/python`. (A bit counterintuitive, but the target of the symlink comes before the symlink name you are making. – tdube Aug 09 '17 at 13:49
  • Hi tdube, yes i know, its just a change in behavior. Thats why simply pip install broke I now need to do pip2 install That not the way most of python 2 developer work. And again, i don't have a problem creating the link, doing that for years. brew all point is help me configure my env so that i won't have to fiddle with symlink on my own. – ohad edelstain Aug 09 '17 at 14:01