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" doesn't work for Python2 #2514

Closed
schedar opened this issue Jul 4, 2018 · 4 comments
Closed

"pipenv shell" doesn't work for Python2 #2514

schedar opened this issue Jul 4, 2018 · 4 comments
Labels
Type: Bug 🐛 This issue is a bug. Type: Regression This issue is a regression of a previous behavior. Type: Vendored Dependencies This issue affects vendored dependencies within pipenv.

Comments

@schedar
Copy link

schedar commented Jul 4, 2018

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": {}
}
@techalchemy techalchemy added Type: Bug 🐛 This issue is a bug. Type: Regression This issue is a regression of a previous behavior. Type: Vendored Dependencies This issue affects vendored dependencies within pipenv. labels Jul 4, 2018
@techalchemy
Copy link
Member

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

@schedar
Copy link
Author

schedar commented Jul 5, 2018

No frustration at all. thank you for the prompt response!
👍

@ixe013
Copy link

ixe013 commented Aug 29, 2018

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.

@jfunction
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug 🐛 This issue is a bug. Type: Regression This issue is a regression of a previous behavior. Type: Vendored Dependencies This issue affects vendored dependencies within pipenv.
Projects
None yet
Development

No branches or pull requests

4 participants