Repository: pypa/pipenv

Issue:
"pipenv shell" doesn't work for Python2
##### Issue description

Running "pipenv shell" for a Python 2.7 project fails.
Using:

* Python 2.7.15
* pip 10.0.1
* pipenv, version 2018.7.1

Seems like "subprocess.run()" has been introduced in shells.py ( in #2371 ), while this api was introduced only from Python 3.

##### Expected result

A cmd shell with virtual environment active should be spawned.

##### Actual result

```
Launching subshell in virtual environment…
Traceback (most recent call last):
  File "c:\program files\python27\lib\runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "c:\program files\python27\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\Program Files\Python27\Scripts\pipenv.exe\__main__.py", line 9, in <module>
  File "c:\program files\python27\lib\site-packages\pipenv\vendor\click\core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "c:\program files\python27\lib\site-packages\pipenv\vendor\click\core.py", line 697, in main
    rv = self.invoke(ctx)
  File "c:\program files\python27\lib\site-packages\pipenv\vendor\click\core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\program files\python27\lib\site-packages\pipenv\vendor\click\core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\program files\python27\lib\site-packages\pipenv\vendor\click\core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "c:\program files\python27\lib\site-packages\pipenv\cli.py", line 664, in shell
    three=three, python=python, fancy=fancy, shell_args=shell_args, pypi_mirror=pypi_mirror
  File "c:\program files\python27\lib\site-packages\pipenv\core.py", line 2159, in do_shell
    shell.fork(*fork_args)
  File "c:\program files\python27\lib\site-packages\pipenv\shells.py", line 97, in fork
    _handover(self.cmd, self.args + list(args))
  File "c:\program files\python27\lib\site-packages\pipenv\shells.py", line 62, in _handover
    proc = subprocess.run(args, shell=True, universal_newlines=True)
AttributeError: 'module' object has no attribute 'run'
```

##### Steps to replicate

```
[packages]

[requires]
python_version = "2.7" 
```

$ pipenv install

-------------

<details><summary>$ pipenv --support</summary>

Pipenv version: `'2018.7.1'`

Pipenv location: `'c:\\program files\\python27\\lib\\site-packages\\pipenv'`

Python location: `'c:\\program files\\python27\\python.exe'`

Other Python installations in `PATH`:

  - `2.7`: `C:\Program Files\Python27\python.exe`

  - `2.7.15`: `C:\Program Files\Python27\python.exe`

PEP 508 Information:

```
{'implementation_name': 'cpython',
 'implementation_version': '0',
 'os_name': 'nt',
 'platform_machine': 'AMD64',
 'platform_python_implementation': 'CPython',
 'platform_release': '10',
 'platform_system': 'Windows',
 'platform_version': '10.0.14393',
 'python_full_version': '2.7.15',
 'python_version': '2.7',
 'sys_platform': 'win32'}
```

System environment variables:

  - `TMP`
  - `COMPUTERNAME`
  - `VS110COMNTOOLS`
  - `USERDOMAIN`
  - `PSMODULEPATH`
  - `COMMANDER_PATH`
  - `IWBPATH`
  - `COMMONPROGRAMFILES`
  - `PROCESSOR_IDENTIFIER`
  - `WECSDK`
  - `PROGRAMFILES`
  - `PROCESSOR_REVISION`
  - `PATH`
  - `SYSTEMROOT`
  - `PROGRAMFILES(X86)`
  - `COMSPEC`
  - `TEMP`
  - `COMMONPROGRAMFILES(X86)`
  - `PROCESSOR_ARCHITECTURE`
  - `PIPENV_VENV_IN_PROJECT`
  - `ALLUSERSPROFILE`
  - `LOCALAPPDATA`
  - `HOMEPATH`
  - `USERDOMAIN_ROAMINGPROFILE`
  - `VS120COMNTOOLS`
  - `PROGRAMW6432`
  - `USERNAME`
  - `LOGONSERVER`
  - `PROMPT`
  - `SESSIONNAME`
  - `PROGRAMDATA`
  - `SAP_IPV6_ACTIVE`
  - `COMMANDER_DRIVE`
  - `COMMANDER_EXE`
  - `USERDNSDOMAIN`
  - `PYTHONDONTWRITEBYTECODE`
  - `UATDATA`
  - `PATHEXT`
  - `PIP_PYTHON_PATH`
  - `CGROAMINGPATH`
  - `WINDIR`
  - `APPDATA`
  - `HOMEDRIVE`
  - `COMMANDER_INI`
  - `SYSTEMDRIVE`
  - `CANOE_INSTALLDIR`
  - `PUBLIC`
  - `NUMBER_OF_PROCESSORS`
  - `CANOE_INSTALLDIR64`
  - `PROCESSOR_LEVEL`
  - `PYTHON_HOME`
  - `COMMONPROGRAMW6432`
  - `OS`
  - `SNC_LIB`
  - `USERPROFILE`

Pipenv–specific environment variables:

 - `PIPENV_VENV_IN_PROJECT`: `1`

Debug–specific environment variables:

  - `PATH`: `C:\Program Files\Python27\;C:\Program Files\Python27\\Scripts;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\WebEx\Productivity Tools;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Micro Focus\StarTeam SDK 16.0\lib;C:\Program Files\Micro Focus\StarTeam SDK 16.0\bin;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Git\cmd;C:\Users\xmnalepa\AppData\Local\Microsoft\WindowsApps;d:\Apps\Sysinternals Suite\;`


---------------------------

Contents of `Pipfile` ('D:\\work\\scripts\\shell_issue\\Pipfile'):

```toml
[packages]

[requires]
python_version = "2.7"

```


Contents of `Pipfile.lock` ('D:\\work\\scripts\\shell_issue\\Pipfile.lock'):

```json
{
    "_meta": {
        "hash": {
            "sha256": "ae4bdd7d4157baab65ae9d0e8389a6011e6b640995372c45ec81fa5d1ddfae9f"
        },
        "pipfile-spec": 6,
        "requires": {
            "python_version": "2.7"
        },
        "sources": [
            {
                "name": "pypi",
                "url": "https://pypi.org/simple",
                "verify_ssl": true
            }
        ]
    },
    "default": {},
    "develop": {}
}

```
</details>



Discussion:

Resolving patch:
diff --git a/pipenv/shells.py b/pipenv/shells.py
--- a/pipenv/shells.py
+++ b/pipenv/shells.py
@@ -59,8 +59,7 @@ def _handover(cmd, args):
     if os.name != "nt":
         os.execvp(cmd, args)
     else:
-        proc = subprocess.run(args, shell=True, universal_newlines=True)
-        sys.exit(proc.returncode)
+        sys.exit(subprocess.call(args, shell=True, universal_newlines=True))
 
 
 class Shell(object):


Test patch: