brew update and retried your prior step?brew doctor, fixed as many issues as possible and retried your prior step?sudo chown -R $(whoami) $(brew --prefix)?pip lost after upgrading python.
pip3 lost after upgrading python3.
Although brew notices me to run brew postinstall python & brew postinstall python3, these commands failed to execute.
> sudo chown -R $(whoami) $(brew --prefix)
> brew postinstall python
==> Using the sandbox
Error: Operation not permitted - (../../../../../../../../../../lib/python2.7/site-packages, /usr/local/Homebrew/Cellar/python/2.7.12_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages)
> brew postinstall python3
==> Using the sandbox
Error: Operation not permitted - (../../../../../../../../../../lib/python3.5/site-packages, /usr/local/Homebrew/Cellar/python3/3.5.2_2/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages)
brew gist-logs python result here
brew gist-logs python3 result here
> brew postinstall python3 -v
==> Using the sandbox
/usr/bin/sandbox-exec -f /tmp/homebrew20161001-36280-ag6wb6.sb nice /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -W0 -I /usr/local/Homebrew/Library/Homebrew -- /usr/local/Homebrew/Library/Homebrew/postinstall.rb /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/python3.rb -v
==> Sandbox log
Oct 1 19:55:54 kernel[0]: Sandbox: ruby(36281) deny(1) file-write-create /usr/local/Homebrew/Cellar/python3/3.5.2_2/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages
Error: Operation not permitted - (../../../../../../../../../../lib/python3.5/site-packages, /usr/local/Homebrew/Cellar/python3/3.5.2_2/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages)
> ll /usr/local/Homebrew/Cellar/python3/3.5.2_2/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages
ls: /usr/local/Homebrew/Cellar/python3/3.5.2_2/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages: No such file or directory
>
> mkdir /usr/local/Homebrew/Cellar/python3/3.5.2_2/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages
> ll /usr/local/Homebrew/Cellar/python3/3.5.2_2/Frameworks/Python.framework/Versions/3.5/lib/python3.5 | grep site-packages
drwxr-xr-x 2 haodong admin 68B Oct 1 19:57 site-packages
> brew postinstall python3 -v
==> Using the sandbox
/usr/bin/sandbox-exec -f /tmp/homebrew20161001-36466-167ihk0.sb nice /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -W0 -I /usr/local/Homebrew/Library/Homebrew -- /usr/local/Homebrew/Library/Homebrew/postinstall.rb /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/python3.rb -v
==> Sandbox log
Oct 1 19:58:02 kernel[0]: Sandbox: ruby(36467) deny(1) file-write-unlink /usr/local/Homebrew/Cellar/python3/3.5.2_2/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages
Oct 1 19:58:02 kernel[0]: Sandbox: ruby(36467) deny(1) file-write-unlink /usr/local/Homebrew/Cellar/python3/3.5.2_2/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages
Error: Operation not permitted - /usr/local/Homebrew/Cellar/python3/3.5.2_2/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages
i just tried https://github.com/Homebrew/homebrew-core/issues/1415#issuecomment-222241990 but useless.
> ll /usr/local/lib | grep python
drwxr-xr-x 3 haodong admin 102B Aug 20 18:16 python2.7
drwxr-xr-x 4 haodong admin 136B Oct 1 19:54 python3.5
> rm -rf /usr/local/lib/python*
> brew update
> brew install python
...
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall python`
...
> brew postinstall python -v
==> Using the sandbox
/usr/bin/sandbox-exec -f /tmp/homebrew20161001-52694-mibrur.sb nice /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -W0 -I /usr/local/Homebrew/Library/Homebrew -- /usr/local/Homebrew/Library/Homebrew/postinstall.rb /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/python.rb -v
==> Sandbox log
Oct 1 20:04:54 kernel[0]: Sandbox: ruby(52695) deny(1) file-write-create /usr/local/Homebrew/Cellar/python/2.7.12_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
Error: Operation not permitted - (../../../../../../../../../../lib/python2.7/site-packages, /usr/local/Homebrew/Cellar/python/2.7.12_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages)
>
> mkdir /usr/local/Homebrew/Cellar/python/2.7.12_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
> ll /usr/local/Homebrew/Cellar/python/2.7.12_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7 | grep site-packages
drwxr-xr-x 2 haodong admin 68B Oct 1 20:05 site-packages
> brew postinstall python -v
==> Using the sandbox
/usr/bin/sandbox-exec -f /tmp/homebrew20161001-52852-1obg6pn.sb nice /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -W0 -I /usr/local/Homebrew/Library/Homebrew -- /usr/local/Homebrew/Library/Homebrew/postinstall.rb /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/python.rb -v
==> Sandbox log
Oct 1 20:06:09 kernel[0]: Sandbox: ruby(52853) deny(1) file-write-unlink /usr/local/Homebrew/Cellar/python/2.7.12_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
Oct 1 20:06:09 kernel[0]: Sandbox: ruby(52853) deny(1) file-write-unlink /usr/local/Homebrew/Cellar/python/2.7.12_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
Error: Operation not permitted - /usr/local/Homebrew/Cellar/python/2.7.12_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
$ pip search test
i get this then i try update not sure if pip fail or homebrew break it... ? :-1:
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/pip/basecommand.py", line 209, in main
status = self.run(options, args)
File "/usr/local/lib/python2.7/site-packages/pip/commands/search.py", line 43, in run
pypi_hits = self.search(query, options)
File "/usr/local/lib/python2.7/site-packages/pip/commands/search.py", line 60, in search
hits = pypi.search({'name': query, 'summary': query}, 'or')
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1240, in __call__
return self.__send(self.__name, args)
File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/xmlrpclib.py", line 1599, in __request
verbose=self.__verbose
File "/usr/local/lib/python2.7/site-packages/pip/download.py", line 764, in request
headers=headers, stream=True)
File "/usr/local/lib/python2.7/site-packages/pip/_vendor/requests/sessions.py", line 511, in post
return self.request('POST', url, data=data, json=json, **kwargs)
File "/usr/local/lib/python2.7/site-packages/pip/download.py", line 378, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/pip/_vendor/requests/sessions.py", line 468, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python2.7/site-packages/pip/_vendor/requests/sessions.py", line 576, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python2.7/site-packages/pip/_vendor/cachecontrol/adapter.py", line 46, in send
resp = super(CacheControlAdapter, self).send(request, **kw)
File "/usr/local/lib/python2.7/site-packages/pip/_vendor/requests/adapters.py", line 447, in send
raise SSLError(e, request=request)
SSLError: EOF occurred in violation of protocol (_ssl.c:590)
@KDGNOR
> pip search test
zsh: command not found: pip
mabye i install pip from https://pip.pypa.io not homebrew then?
i install openssl and alot of brew broke....
so i think mabye it broke pip download/search too?
Same happened to me (in python3), but I first tried brew reinstall python3 and it gave me this error/warning:
error: could not delete '/usr/local/lib/python3.5/site-packages/pkg_resources/__init__.py': Permission denied
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall python3`
brew doctor gave me nothing (related) but running sudo chown -R $(whoami) $(brew --prefix) and then brew postinstall python3 solved it.
@Bilkow
You're lucky. I got:
> sudo chown -R $(whoami) $(brew --prefix)
Password:
> brew postinstall python3
==> Using the sandbox
Error: Operation not permitted - (../../../../../../../../../../lib/python3.5/site-packages, /usr/local/Homebrew/Cellar/python3/3.5.2_2/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages)
> brew postinstall python3 -v
==> Using the sandbox
/usr/bin/sandbox-exec -f /tmp/homebrew20161005-1386-eadq47.sb nice /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -W0 -I /usr/local/Homebrew/Library/Homebrew -- /usr/local/Homebrew/Library/Homebrew/postinstall.rb /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/python3.rb -v
==> Sandbox log
Oct 5 11:32:10 sandboxd[401]: ruby(1387) deny file-write-create /usr/local/Homebrew/Cellar/python3/3.5.2_2/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages
Error: Operation not permitted - (../../../../../../../../../../lib/python3.5/site-packages, /usr/local/Homebrew/Cellar/python3/3.5.2_2/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages)
I have the same issue as https://github.com/Homebrew/homebrew-core/issues/5419#issuecomment-250908985 when running brew postinstall python:
$ brew postinstall python -v
==> Using the sandbox
/usr/bin/sandbox-exec -f /tmp/homebrew20161005-5149-10brfim.sb nice /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby -W0 -I /usr/local/homebrew/Library/Homebrew -- /usr/local/homebrew/Library/Homebrew/postinstall.rb /usr/local/homebrew/Library/Taps/homebrew/homebrew-core/Formula/python.rb -v
Error: Operation not permitted - (../../../../../../../../../../lib/python2.7/site-packages, /usr/local/homebrew/Cellar/python/2.7.12_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages)
However, I've fixed that by running python -m ensurepip then both pip and setuptools are installed successfully at /usr/local/homebrew/Cellar/python/2.7.12_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages and you can find commands pip and easy_install from /usr/local/homebrew/Cellar/python/2.7.12_1/Frameworks/Python.framework/Versions/2.7/bin although it doesn't create any symbolic links under /usr/local/bin automatically. so I have to manually create those symbolic links:
$ cd /usr/local/homebrew/Cellar/python/2.7.12_1/bin/
$ ln -s ../Frameworks/Python.framework/Versions/2.7/bin/pip
$ ln -s ../Frameworks/Python.framework/Versions/2.7/bin/easy_install
$ cd /usr/local/bin
$ ln -s ../homebrew/Cellar/python/2.7.12_1/bin/pip
$ ln -s ../homebrew/Cellar/python/2.7.12_1/bin/easy_install
I ran in to the same issue with the same symptoms, and bilkow's fix worked for me. Mac OS 10.11.
+1 on bilkow's solution
I believe this is related to https://github.com/Homebrew/brew/pull/1101; sandbox log has:
Sep 30 19:39:56 kernel[0]: Sandbox: ruby(32623) deny(1) file-write-create /usr/local/Homebrew/Cellar/python/2.7.12_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
cc @MikeMcQuaid
@tdsmith I've opened https://github.com/Homebrew/brew/pull/1261 and https://github.com/Homebrew/brew/pull/1262 to address this.
Relatedly, everyone in this thread seems to have a /usr/local/[Hh]omebrew/Cellar directory and a /usr/local/prefix. This will result in you not being able to use a bunch of our binary packages. I recommend moving your Cellar to /usr/local/Cellar and, if needed (it may be, I'm not sure) reinstall your packages (do this easily with brew bundle dump; brew uninstall --force $(brew list); brew bundle).
@MikeMcQuaid /usr/local/Homebrew/Cellar doesn't exist for me though. My Cellar is /usr/local/Cellar, my prefix /usr/local and my repository /usr/local/Homebrew.
I guess this explains why some have not managed to fix it, but not why/how pip[3] has gone missing.
@Bilkow I have.
If you reinstall Homebrew with the new installer script. It will have either.
OK. Now I'm regretting that should not reinstall the new one.
I had same problem that pip3 is not recognized after brew update and brew upgrade. This https://github.com/Homebrew/homebrew-core/issues/5419#issuecomment-251494916 has solution
$ which pip2
/usr/local/bin/pip2
$ which pip3
/usr/local/bin/pip3
$ which pip
/usr/local/bin/pip
$ pip
-bash: /usr/local/bin/pip: /usr/local/opt/python3/bin/python3.5: bad interpreter: No such file or directory
If I pip2 or pip3 no error message would pop up, but just all packages install under python3 has gone.
It's a shamed that I step into this hole after almost a month... should have check issues more often:(
Just a guess: it seems that there's some problem with the shortcut?
For myself:
Reinstalled macOS and everything becomes OK. (reinstalling homebrew was not a solution to me)
We can't really consider reinstall the whole system as a solution, I think...
Have you tried uninstall both versions of python and start clean?
Yes, and not helpful. It's frustrating.
As far as I can remember, the default pip is pip2(pip of python2), right?
I kind of 'fixed' it by $sudo pip2 install --upgrade pip.
After that, except python3 packages are still gone, $pip won't pop up any error message.
However one thing still bothers me is whether the installed packages are still existing somewhere or just been removed with the upgrade?
Sigh...
I have the same problem & none of these solutions solved my issue, any clue how to fix it, reinstalling the OS is not an option.
@ahmedelgabri please open a new issue and complete the issue template if you're having a problem.
Most helpful comment
Same happened to me (in python3), but I first tried
brew reinstall python3and it gave me this error/warning:brew doctorgave me nothing (related) but runningsudo chown -R $(whoami) $(brew --prefix)and thenbrew postinstall python3solved it.