Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pip missed after upgrading both python2 and python3 #5419

Closed
3 tasks done
ghost opened this issue Sep 30, 2016 · 23 comments
Closed
3 tasks done

pip missed after upgrading both python2 and python3 #5419

ghost opened this issue Sep 30, 2016 · 23 comments
Labels
bug Reproducible Homebrew/homebrew-core bug python Python use is a significant feature of the PR or issue sandbox Homebrew's use of the macOS Sandbox

Comments

@ghost
Copy link

ghost commented Sep 30, 2016

Please follow the general troubleshooting steps first:

  • Ran brew update and retried your prior step?
  • Ran brew doctor, fixed as many issues as possible and retried your prior step?
  • If you're seeing permission errors tried running sudo chown -R $(whoami) $(brew --prefix)?

Bug reports:

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

@ghost
Copy link
Author

ghost commented Oct 1, 2016

> 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

@ghost
Copy link
Author

ghost commented Oct 1, 2016

i just tried #1415 (comment) 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

@KDGNOR
Copy link

KDGNOR commented Oct 1, 2016

$ pip search test
i get this then i try update not sure if pip fail or homebrew break it... ? 👎

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)

@ghost
Copy link
Author

ghost commented Oct 1, 2016

@KDGNOR

> pip search test
zsh: command not found: pip

@KDGNOR
Copy link

KDGNOR commented Oct 1, 2016

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?

@pheki
Copy link

pheki commented Oct 4, 2016

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.

@ghost
Copy link
Author

ghost commented Oct 5, 2016

@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)

@shawnzhu
Copy link

shawnzhu commented Oct 6, 2016

I have the same issue as #5419 (comment) 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

@michaelbrundage
Copy link

I ran in to the same issue with the same symptoms, and bilkow's fix worked for me. Mac OS 10.11.

@merrywhether
Copy link

merrywhether commented Oct 9, 2016

+1 on bilkow's solution

@tdsmith
Copy link
Contributor

tdsmith commented Oct 11, 2016

I believe this is related to Homebrew/brew#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 tdsmith added bug Reproducible Homebrew/homebrew-core bug python Python use is a significant feature of the PR or issue sandbox Homebrew's use of the macOS Sandbox labels Oct 11, 2016
@MikeMcQuaid
Copy link
Member

@tdsmith I've opened Homebrew/brew#1261 and Homebrew/brew#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).

@pheki
Copy link

pheki commented Oct 12, 2016

@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.

@ghost
Copy link
Author

ghost commented Oct 12, 2016

@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.

@ogail
Copy link

ogail commented Nov 27, 2016

I had same problem that pip3 is not recognized after brew update and brew upgrade. This #5419 (comment) has solution

@spencerzhang91
Copy link

spencerzhang91 commented Dec 26, 2016

$ 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?

@ghost
Copy link
Author

ghost commented Dec 26, 2016

For myself:
Reinstalled macOS and everything becomes OK. (reinstalling homebrew was not a solution to me)

@ghost ghost closed this as completed Dec 26, 2016
@spencerzhang91
Copy link

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?

@ghost
Copy link
Author

ghost commented Dec 26, 2016

Yes, and not helpful. It's frustrating.

@spencerzhang91
Copy link

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.

@spencerzhang91
Copy link

However one thing still bothers me is whether the installed packages are still existing somewhere or just been removed with the upgrade?
Sigh...

@ahmedelgabri
Copy link
Contributor

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.

@ilovezfs
Copy link
Contributor

ilovezfs commented Aug 2, 2017

@ahmedelgabri please open a new issue and complete the issue template if you're having a problem.

@Homebrew Homebrew locked and limited conversation to collaborators Aug 2, 2017
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Reproducible Homebrew/homebrew-core bug python Python use is a significant feature of the PR or issue sandbox Homebrew's use of the macOS Sandbox
Projects
None yet
Development

No branches or pull requests