pipenv icon indicating copy to clipboard operation
pipenv copied to clipboard

Pipenv Shell command not activating the environment

Open Suraj-Mittal opened this issue 3 years ago • 11 comments

Hi! My pipenv shell is not activating the environment as it is giving some file not found error. I tried uninstalling and reinstalling pipenv and even the python. I also tried searching for the solution on the internet but couldn't find any. The same issue was raised by someone on GitHub but it is closed without solving the issue. Please help as none of my python projects are working now.

Using Windows 11, Python 3.10

Below is the error its giving out

D:\VS Code\Python\PyYelp>pipenv shell
Launching subshell in virtual environment...
Traceback (most recent call last):
  File "C:\Users\suraj\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\suraj\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\suraj\AppData\Local\Programs\Python\Python310\Scripts\pipenv.exe\__main__.py", line 7, in <module>
  File "C:\Users\suraj\AppData\Local\Programs\Python\Python310\lib\site-packages\pipenv\vendor\click\core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\suraj\AppData\Local\Programs\Python\Python310\lib\site-packages\pipenv\cli\options.py", line 57, in main
    return super().main(*args, **kwargs, windows_expand_args=False)
  File "C:\Users\suraj\AppData\Local\Programs\Python\Python310\lib\site-packages\pipenv\vendor\click\core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "C:\Users\suraj\AppData\Local\Programs\Python\Python310\lib\site-packages\pipenv\vendor\click\core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "C:\Users\suraj\AppData\Local\Programs\Python\Python310\lib\site-packages\pipenv\vendor\click\core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\suraj\AppData\Local\Programs\Python\Python310\lib\site-packages\pipenv\vendor\click\core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "C:\Users\suraj\AppData\Local\Programs\Python\Python310\lib\site-packages\pipenv\vendor\click\decorators.py", line 84, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "C:\Users\suraj\AppData\Local\Programs\Python\Python310\lib\site-packages\pipenv\vendor\click\core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "C:\Users\suraj\AppData\Local\Programs\Python\Python310\lib\site-packages\pipenv\cli\command.py", line 398, in shell
    do_shell(
  File "C:\Users\suraj\AppData\Local\Programs\Python\Python310\lib\site-packages\pipenv\core.py", line 2562, in do_shell
    shell.fork(*fork_args)
  File "C:\Users\suraj\AppData\Local\Programs\Python\Python310\lib\site-packages\pipenv\shells.py", line 97, in fork
    _handover(self.cmd, self.args + list(args))
  File "C:\Users\suraj\AppData\Local\Programs\Python\Python310\lib\site-packages\pipenv\shells.py", line 62, in _handover
    sys.exit(subprocess.call(args, shell=True, universal_newlines=True))
  File "C:\Users\suraj\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 345, in call
    with Popen(*popenargs, **kwargs) as p:
  File "C:\Users\suraj\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 969, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "C:\Users\suraj\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 1438, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] The system cannot find the file specified

Suraj-Mittal avatar Sep 17 '22 06:09 Suraj-Mittal

@Suraj-Mittal What was the other issue report? In debugging, have you tried re-creating your virtualenv with pipenv --rm and pipenv sync?

matteius avatar Sep 17 '22 07:09 matteius

Thanks for the reply. Yes, I tried recreating the environment but the issue is still there.

Here is the link for the similar issue reported: https://github.com/pypa/pipenv/issues/4413

Suraj-Mittal avatar Sep 17 '22 07:09 Suraj-Mittal

@Suraj-Mittal Please verify that you are on pipenv==2022.9.8 -- also have you tried the main branch yet?

matteius avatar Sep 17 '22 07:09 matteius

I am exactly using that version and I am sorry I don't know what you mean by the main branch.

Suraj-Mittal avatar Sep 17 '22 07:09 Suraj-Mittal

@Suraj-Mittal Very possible you'll get the same error on main branch, but just in case since there have been a few changes since last release, you could try pip uninstall pipenv --yes and then I think pip install git+https://github.com/pypa/pipenv.git@main#egg=pipenv

Also -- which terminal are you using?

matteius avatar Sep 17 '22 07:09 matteius

I am using the command prompt.

Update: I tried the commands you mentioned, but the issue is still there.

Suraj-Mittal avatar Sep 17 '22 07:09 Suraj-Mittal

@Suraj-Mittal Do you happen to have either of these variables set: echo %PIPENV_SHELL% echo %PIPENV_SHELL_FANCY%

matteius avatar Sep 17 '22 07:09 matteius

I am actually new to this! Are you talking about environment variables?

Suraj-Mittal avatar Sep 17 '22 07:09 Suraj-Mittal

Yes on environment variable. the problem for me debugging this is the stack trace is clear, but the error is not -- I am guessing it cannot find the executable/command specified, but I am not really sure. You are helping me narrow which code paths I look at.

If you are on the Python Developers slack group we could chat there in real time right now too.

matteius avatar Sep 17 '22 07:09 matteius

No, I am not there but you can help me to setup.

Update: I joined the slack group. What's next?

Suraj-Mittal avatar Sep 17 '22 07:09 Suraj-Mittal

@Suraj-Mittal Would you be willing to try the same thing using Windows Power Shell just to see if its different?

Also, I just sent a Suraj Mittal a message on the slack group -- let me know if that is you.

matteius avatar Sep 17 '22 07:09 matteius