question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Completion is not working with zsh on macOS

See original GitHub issue

Maybe this is related to #226 ?

$ pipsi install pipenv
Running virtualenv with interpreter /Users/markus/.local/venvs/pipsi/bin/python3.6
Using real prefix '/usr/local/var/pyenv/versions/3.6.1'
New python executable in /Users/markus/.local/venvs/pipenv/bin/python3.6
Also creating executable in /Users/markus/.local/venvs/pipenv/bin/python
Installing setuptools, pip, wheel...done.
Collecting pipenv
Collecting pew>=0.1.26 (from pipenv)
  Using cached pew-0.1.26-py2.py3-none-any.whl
Requirement already satisfied: pip in ./.local/venvs/pipenv/lib/python3.6/site-packages (from pipenv)
Collecting virtualenv (from pipenv)
  Using cached virtualenv-15.1.0-py2.py3-none-any.whl
Collecting pythonz-bd>=1.10.2 (from pew>=0.1.26->pipenv)
  Using cached pythonz_bd-1.11.4-py3-none-any.whl
Collecting virtualenv-clone>=0.2.5 (from pew>=0.1.26->pipenv)
Requirement already satisfied: setuptools>=17.1 in ./.local/venvs/pipenv/lib/python3.6/site-packages (from pew>=0.1.26->pipenv)
Collecting resumable-urlretrieve; python_version == "3.6" (from pythonz-bd>=1.10.2->pew>=0.1.26->pipenv)
  Using cached resumable_urlretrieve-0.1.5-py2.py3-none-any.whl
Collecting requests (from resumable-urlretrieve; python_version == "3.6"->pythonz-bd>=1.10.2->pew>=0.1.26->pipenv)
  Downloading requests-2.18.2-py2.py3-none-any.whl (88kB)
    100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 92kB 1.7MB/s
Collecting certifi>=2017.4.17 (from requests->resumable-urlretrieve; python_version == "3.6"->pythonz-bd>=1.10.2->pew>=0.1.26->pipenv)
  Using cached certifi-2017.4.17-py2.py3-none-any.whl
Collecting urllib3<1.23,>=1.21.1 (from requests->resumable-urlretrieve; python_version == "3.6"->pythonz-bd>=1.10.2->pew>=0.1.26->pipenv)
  Downloading urllib3-1.22-py2.py3-none-any.whl (132kB)
    100% |β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 133kB 3.4MB/s
Collecting idna<2.6,>=2.5 (from requests->resumable-urlretrieve; python_version == "3.6"->pythonz-bd>=1.10.2->pew>=0.1.26->pipenv)
  Using cached idna-2.5-py2.py3-none-any.whl
Collecting chardet<3.1.0,>=3.0.2 (from requests->resumable-urlretrieve; python_version == "3.6"->pythonz-bd>=1.10.2->pew>=0.1.26->pipenv)
  Using cached chardet-3.0.4-py2.py3-none-any.whl
Installing collected packages: certifi, urllib3, idna, chardet, requests, resumable-urlretrieve, pythonz-bd, virtualenv, virtualenv-clone, pew, pipenv
Successfully installed certifi-2017.4.17 chardet-3.0.4 idna-2.5 pew-0.1.26 pipenv-5.1.2 pythonz-bd-1.11.4 requests-2.18.2 resumable-urlretrieve-0.1.5 urllib3-1.22 virtualenv-15.1.0 virtualenv-clone-0.2.6
  Linked script /Users/markus/.local/bin/pipenv
Done.
$ pipenv --version
pipenv, version 5.1.2
$ _PIPENV_COMPLETE=source pipenv
Traceback (most recent call last):
  File "/Users/markus/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/vendor/click_completion.py", line 409, in get_auto_shell
    import psutil
  File "/Users/markus/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/vendor/psutil/__init__.py", line 136, in <module>
    from . import _psosx as _psplatform
  File "/Users/markus/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/vendor/psutil/_psosx.py", line 14, in <module>
    from . import _psutil_osx as cext
ImportError: cannot import name '_psutil_osx'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/markus/.local/bin/pipenv", line 11, in <module>
    sys.exit(cli())
  File "/Users/markus/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/Users/markus/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 692, in main
    _bashcomplete(self, prog_name, complete_var)
  File "/Users/markus/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/vendor/click_completion.py", line 297, in _shellcomplete
    echo(get_code(prog_name=prog_name, env_name=complete_var))
  File "/Users/markus/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/vendor/click_completion.py", line 387, in get_code
    shell = get_auto_shell()
  File "/Users/markus/.local/venvs/pipenv/lib/python3.6/site-packages/pipenv/vendor/click_completion.py", line 415, in get_auto_shell
    raise click.UsageError("Please explicitly give the shell type or install the psutil package to activate the"
click.exceptions.UsageError: Please explicitly give the shell type or install the psutil package to activate the automatic shell detection.
$ _PIPENV_COMPLETE=source-zsh pipenv

#compdef pipenv
_pipenv() {
  eval $(env COMMANDLINE="${words[1,$CURRENT]}" _PIPENV_COMPLETE=complete-zsh  pipenv)
}
if [[ "$(basename ${(%):-%x})" != "_pipenv" ]]; then
  autoload -U compinit && compinit
  compdef _pipenv pipenv
fi

But it’s not completing anything …

$ eval $(_PIPENV_COMPLETE=source-zsh pipenv)
$ pipenv i<Tab>
-- file --
Applications/             Downloads/                Movies/                   VirtualBox\ VMs/

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:20 (10 by maintainers)

github_iconTop GitHub Comments

6reactions
dklotzcommented, Mar 12, 2018

Ok, I found a workaround which "works for me"ℒ️, but expects oh-my-zsh to be used:

pipenv --completion >> .oh-my-zsh/custom/pipenv_completion.zsh

All files there get auto-loaded on zsh startup. Bonus: It’s faster since pipenv does not need to be executed on shell startup. I’m sure there are standard/non-oh-my-zsh places that can be used instead, but my vanilla-zsh-fu is not strong enough for this.

2reactions
tilgovicommented, Aug 30, 2017

Ooh, wait. I was forgetting to quote it on my Mac.

eval β€œ$(_PIPENV_COMPLETE=source-zsh pipenv)”

… yields β€œbasename: illegal option – z”

Read more comments on GitHub >

github_iconTop Results From Across the Web

Git tab completion not working in zsh on mac - Stack Overflow
No matter what I try and do I can't seem to make git tab/auto completion work in my zsh shell. I've downloaded the...
Read more >
macOS Fix Zsh auto-completion and get more - Sindastra
If you add additional auto-completions, but they don't work, you might have to clear the cache and rebuild, you can do so with:...
Read more >
Moving to zsh, part 5: Completions - Scripting OS X
Because at the beginning of the command line, it doesn't complete directories. Many other issues with completion make livign with zsh annoying.
Read more >
macOS transition from Bash to Zsh | by Remo Hoeppli - Medium
This blog post is about my findings from my personal transition from Bash to Zsh and describes how I got auto-completion for some...
Read more >
Seems broken in zsh on macOS Β· Issue #41 Β· lincheney/fzf-tab ...
can you tell me what git commit you are on and what is the md5sum on fzf-zsh-completion.sh ?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found