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

pipenv shell does not work with PowerShell Core #1689

Closed
brettcannon opened this issue Mar 13, 2018 · 9 comments
Closed

pipenv shell does not work with PowerShell Core #1689

brettcannon opened this issue Mar 13, 2018 · 9 comments
Labels
OS: Windows This issue affects the Windows Operating System. Type: Bug 🐛 This issue is a bug.

Comments

@brettcannon
Copy link
Member

Running pipenv shell under PowerShell Core does not work.

Pipenv version: '11.6.1'

Pipenv location: 'C:\\Users\\brcan\\AppData\\Roaming\\Python\\Python36\\site-packages\\pipenv'

Python location: 'C:\\Users\\brcan\\AppData\\Local\\Programs\\Python\\Python36\\python.exe'

Other Python installations in PATH:


Expected result

pipenv shell to execute the Activate.ps1 script for the virtual environment.

Actual result
PS C:\Users\brcan\Desktop\bunk> py -3 -m pipenv shell
Traceback (most recent call last):
  File "C:\Users\brcan\AppData\Roaming\Python\Python36\site-packages\pipenv\core.py", line 2107, in do_shell
    c = pexpect.spawn(
AttributeError: module 'pexpect' has no attribute 'spawn'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\brcan\AppData\Local\Programs\Python\Python36\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Users\brcan\AppData\Local\Programs\Python\Python36\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\brcan\AppData\Roaming\Python\Python36\site-packages\pipenv\__main__.py", line 4, in <module>
    cli()
  File "C:\Users\brcan\AppData\Roaming\Python\Python36\site-packages\pipenv\vendor\click\core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\brcan\AppData\Roaming\Python\Python36\site-packages\pipenv\vendor\click\core.py", line 697, in main
    rv = self.invoke(ctx)
  File "C:\Users\brcan\AppData\Roaming\Python\Python36\site-packages\pipenv\vendor\click\core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\brcan\AppData\Roaming\Python\Python36\site-packages\pipenv\vendor\click\core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\brcan\AppData\Roaming\Python\Python36\site-packages\pipenv\vendor\click\core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "C:\Users\brcan\AppData\Roaming\Python\Python36\site-packages\pipenv\cli.py", line 281, in shell
    core.do_shell(three=three, python=python, fancy=fancy, shell_args=shell_args)
  File "C:\Users\brcan\AppData\Roaming\Python\Python36\site-packages\pipenv\core.py", line 2123, in do_shell
    pew.workon_cmd([workon_name])
  File "C:\Users\brcan\AppData\Roaming\Python\Python36\site-packages\pipenv\patched\pew\pew.py", line 368, in workon_cmd
    shell(env, cwd=project_dir)
  File "C:\Users\brcan\AppData\Roaming\Python\Python36\site-packages\pipenv\patched\pew\pew.py", line 194, in shell
    shell = _detect_shell()
  File "C:\Users\brcan\AppData\Roaming\Python\Python36\site-packages\pipenv\patched\pew\pew.py", line 187, in _detect_shell
    shell = get_shell(os.getpid())
  File "C:\Users\brcan\AppData\Roaming\Python\Python36\site-packages\pipenv\patched\pew\_win_utils.py", line 111, in get_shell
    return check_parent(pid)
  File "C:\Users\brcan\AppData\Roaming\Python\Python36\site-packages\pipenv\patched\pew\_win_utils.py", line 108, in check_parent
    return check_parent(ppid, lvl=lvl+1)
  File "C:\Users\brcan\AppData\Roaming\Python\Python36\site-packages\pipenv\patched\pew\_win_utils.py", line 108, in check_parent
    return check_parent(ppid, lvl=lvl+1)
  File "C:\Users\brcan\AppData\Roaming\Python\Python36\site-packages\pipenv\patched\pew\_win_utils.py", line 108, in check_parent
    return check_parent(ppid, lvl=lvl+1)
  File "C:\Users\brcan\AppData\Roaming\Python\Python36\site-packages\pipenv\patched\pew\_win_utils.py", line 104, in check_parent
    if ppid and processes[ppid]['executable'].lower().rsplit('.', 1)[0] in SHELL_NAMES:
KeyError: 18064
Steps to replicate
PS C:\Users\brcan\Desktop\bunk> py -3 -m pipenv --python 3.6.4
Virtualenv already exists!
Removing existing virtualenv…
Creating a virtualenv for this project…
Using C:\Users\brcan\AppData\Local\Programs\Python\Python36\python.exe (3.6.4) to create virtualenv…
Already using interpreter C:\Users\brcan\AppData\Local\Programs\Python\Python36\python.exe
Using base prefix 'C:\\Users\\brcan\\AppData\\Local\\Programs\\Python\\Python36'
New python executable in C:\Users\brcan\.virtualenvs\bunk-M_X9FcBv\Scripts\python.exe
Installing setuptools, pip, wheel...done.

Virtualenv location: C:\Users\brcan\.virtualenvs\bunk-M_X9FcBv
Creating a Pipfile for this project…
PS C:\Users\brcan\Desktop\bunk> py -3 -m pipenv shell
@kennethreitz
Copy link
Contributor

thanks for the report!

@kennethreitz kennethreitz added the Type: Bug 🐛 This issue is a bug. label Mar 13, 2018
@techalchemy
Copy link
Member

ooh that's an interesting one.

@brettcannon for the record we don't invoke Activate.ps1 currently, or most other activation scripts -- thus the subshelling. I think the pexpect issue is an import issue, and well the ppid issue is obvious

Gonna have to tag @uranusjr for the virtualenv replacement there, I'm working on some finder tools that use the pep514 implementation but haven't swapped it in yet. Wonder if this is normalization related

@uranusjr
Copy link
Member

FWIW I can use pipenv shell correctly with Powershell Core on macOS, so this is likely more a Windows issue than PS Core. I don’t have access to my Windows machine right now, however, and will need to explore this later.

@kennethreitz kennethreitz added the OS: Windows This issue affects the Windows Operating System. label Mar 13, 2018
@kennethreitz
Copy link
Contributor

@erinxocon want to take a look?

@uranusjr
Copy link
Member

I think I got it. Pull request coming up (but I need some help with click_completion).

@kennethreitz
Copy link
Contributor

@uranusjr we can disable it on windows.

@uranusjr
Copy link
Member

I think it’s good to keep it as-is. Powershell Core is not officially supported by click-completion anyway, so people shouldn’t expect much in the first place.

@kennethreitz
Copy link
Contributor

fixed in master

@techalchemy
Copy link
Member

I'm fixing those calls in pew._win_utils as well

techalchemy added a commit that referenced this issue Mar 13, 2018
techalchemy added a commit that referenced this issue Mar 13, 2018
- Add escaping to allow spaces in paths (regressed)
- Final fix for #1689
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OS: Windows This issue affects the Windows Operating System. Type: Bug 🐛 This issue is a bug.
Projects
None yet
Development

No branches or pull requests

5 participants