Pipenv: "pipenv shell" doesn't work for Python2

Created on 4 Jul 2018  Â·  4Comments  Â·  Source: pypa/pipenv

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


$ pipenv --support

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'):

[packages]

[requires]
python_version = "2.7"

Contents of Pipfile.lock ('D:\work\scripts\shell_issue\Pipfile.lock'):

{
    "_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": {}
}

Type Regression Vendored Dependencies

Most helpful comment

What worked for me on Windows with Python 3.4 was to downgrade pipenv (for now).
pip install pipenv==2018.6.25
(possibly throw a --user in there)
Thanks for the work on pipenv btw, I'm doing my bit to spread the word :)

All 4 comments

Thanks for the report and sorry for the frustration. We do strongly recommend installing pipenv with python 3 which would provide a short term solution until next release

No frustration at all. thank you for the prompt response!
:+1:

Here is a workaround I use on Windows. Put this in a batch file, say pipenvshell.bat

@for %%F in ("%cd%") do @set "folder=%%~nxF"
pipenv run cmd /k "title %FOLDER% && prompt (venv)$S%PROMPT%^"

Running pipenvshell will get you a pipenv shell with the title of the window renamed to the name of your current folder and your prompt prefixed with (venv).

Doing the same on Linux left as an exercice for the reader.

What worked for me on Windows with Python 3.4 was to downgrade pipenv (for now).
pip install pipenv==2018.6.25
(possibly throw a --user in there)
Thanks for the work on pipenv btw, I'm doing my bit to spread the word :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jacek-jablonski picture jacek-jablonski  Â·  3Comments

fbender picture fbender  Â·  3Comments

erinxocon picture erinxocon  Â·  3Comments

ipmb picture ipmb  Â·  3Comments

Californian picture Californian  Â·  3Comments