pipenv: AssertionError on pipenv install in ubuntu trusty docker

I try to use pipenv in a docker container based on ubuntu trusty. Basically bare metal except for some security patches like apt-get install libssl-dev, libffi-dev and pip install requests[security]

I can run pipenv but whenever I try to call pipenv install I get the following output

root@782753ee5bc0:/# pipenv install requests
Creating a virtualenv for this project…
Using /usr/bin/python (2.7.6) to create virtualenv…
⠋usage: __main__.py [-h] [-p PYTHON] [-i PACKAGES] [-r REQUIREMENTS] [-d]
                   [-a PROJECT]
                   envname
__main__.py: error: too few arguments

Virtualenv location: 
Creating a Pipfile for this project…
Traceback (most recent call last):
  File "/usr/local/bin/pipenv", line 11, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python2.7/dist-packages/pipenv/vendor/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/pipenv/vendor/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/dist-packages/pipenv/vendor/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/dist-packages/pipenv/vendor/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/dist-packages/pipenv/vendor/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/pipenv/cli.py", line 402, in install
    selective_upgrade=selective_upgrade,
  File "/usr/local/lib/python2.7/dist-packages/pipenv/core.py", line 1781, in do_install
    skip_requirements=skip_requirements,
  File "/usr/local/lib/python2.7/dist-packages/pipenv/core.py", line 650, in ensure_project
    ensure_pipfile(validate=validate, skip_requirements=skip_requirements, system=system)
  File "/usr/local/lib/python2.7/dist-packages/pipenv/core.py", line 304, in ensure_pipfile
    project.create_pipfile(python=python)
  File "/usr/local/lib/python2.7/dist-packages/pipenv/project.py", line 571, in create_pipfile
    config_parser = ConfigOptionParser(name=self.name)
  File "/usr/local/lib/python2.7/dist-packages/pipenv/vendor/pip9/baseparser.py", line 149, in __init__
    assert self.name
AssertionError
/usr/local/lib/python2.7/dist-packages/pipenv/_compat.py:86: ResourceWarning: Implicitly cleaning up <TemporaryDirectory '/tmp/pipenv-bI5NJZ-requirements'>
  warnings.warn(warn_message, ResourceWarning)

Running $ python -m pipenv.help yields:

$ python -m pipenv.help output

Pipenv version: '2018.05.18'

Pipenv location: '/usr/local/lib/python2.7/dist-packages/pipenv'

Python location: '/usr/bin/python'

Other Python installations in PATH:

  • 2.7: /usr/bin/python2.7

  • 2.7: /usr/bin/python2.7

  • 3.4: /usr/bin/python3.4m

  • 3.4: /usr/bin/python3.4

  • 2.7.6: /usr/bin/python

  • 2.7.6: /usr/bin/python2

  • 3.4.3: /usr/bin/python3

PEP 508 Information:

{'implementation_name': 'cpython',
 'implementation_version': '0',
 'os_name': 'posix',
 'platform_machine': 'x86_64',
 'platform_python_implementation': 'CPython',
 'platform_release': '4.9.60-linuxkit-aufs',
 'platform_system': 'Linux',
 'platform_version': '#1 SMP Mon Nov 6 16:00:12 UTC 2017',
 'python_full_version': '2.7.6',
 'python_version': '2.7',
 'sys_platform': 'linux2'}

System environment variables:

  • LANG
  • TERM
  • LESSCLOSE
  • LANGUAGE
  • SHLVL
  • HOSTNAME
  • PYTHONDONTWRITEBYTECODE
  • LESSOPEN
  • PWD
  • PATH
  • LC_ALL
  • PIP_PYTHON_PATH
  • LS_COLORS
  • HOME
  • _

Pipenv–specific environment variables:

Debug–specific environment variables:

  • PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
  • LANG: en_US.UTF-8
  • PWD: /

Steps to replicate

Dockerfile

FROM ubuntu:trusty

RUN apt-get update && apt-get dist-upgrade -y && apt-get autoremove -y
&& apt-get install -y --force-yes --no-install-recommends
apt-transport-https
curl
ca-certificates
automake
python-dev
language-pack-en
libffi-dev
libssl-dev
&& apt-get clean

RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py && python get-pip.py RUN python get-pip.py --force-reinstall RUN pip install requests[security]

ENV LANG en_US.UTF-8 ENV LANGUAGE en_US.UTF-8 ENV LC_ALL en_US.UTF-8 RUN locale-gen && dpkg-reconfigure locales RUN pip install pipenv RUN pipenv install requests

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 18 (9 by maintainers)

Most upvoted comments

Running pipenv shell --fancy circumvents the problem

root@89918561ad95:/foo# pipenv shell --fancy
Launching subshell in virtual environment. Type 'exit' or 'Ctrl+D' to return.
# 

after I touched a Pipfile, the problem solved…

Good luck on that! My invitation regarding documentation contributions still stands though 😃

root@89918561ad95:/foo# echo "$SHELL"
/bin/bash

Still I can’t spawn the shell

root@89918561ad95:/foo# pipenv shell 
Please ensure that the SHELL environment variable is set before activating shell.

I actually have to add export SHELL=/bin/bash to .bashrc to make this work. Is this the intended behaviour?

SHELL is a widely-used environment variable in POSIX systems, used to determine the user’s preferred shell. It is expected to be set to the absolute path of the shell you would like to use, e.g. /bin/bash. Pipenv uses the variable to determine what shell it should launch.

The documentation does assume quite some knowledge on development environment and Python packaging to be consumed. Please do help to clarify if you find it difficult to understand!