pipenv fails to install python with pyenv in non-interactive environments

Created on 21 Nov 2018  Â·  3Comments  Â·  Source: pypa/pipenv

I have setup pipenv and pyenv in a CI system, with the expectation that if a required version of python was not installed pipenv would invoke pyenv to install the correct version. This works fine in an interactive terminal but fails when run in the CI system.

When attempting to execute "pipenv install" I get the following error:

Warning: Your Pipfile requires python_version 3.7, but you are using 2.7.14 (/opt/j/home/.local/share/v/s/bin/python).
  $ pipenv --rm and rebuilding the virtual environment may resolve the issue.
  $ pipenv check will surely fail.
Launching subshell in virtual environment…
Traceback (most recent call last):
  File "/usr/local/bin/pipenv", line 11, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python2.7/site-packages/pipenv/vendor/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/pipenv/vendor/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/site-packages/pipenv/vendor/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python2.7/site-packages/pipenv/vendor/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/pipenv/vendor/click/decorators.py", line 64, in new_func
    return ctx.invoke(f, obj, *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/pipenv/vendor/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/pipenv/cli/command.py", line 374, in shell
    pypi_mirror=state.pypi_mirror,
  File "/usr/local/lib/python2.7/site-packages/pipenv/core.py", line 2088, in do_shell
    shell.fork_compat(*fork_args)
  File "/usr/local/lib/python2.7/site-packages/pipenv/shells.py", line 121, in fork_compat
    c.interact(escape_character=None)
  File "/usr/local/lib/python2.7/site-packages/pipenv/vendor/pexpect/pty_spawn.py", line 761, in interact
    mode = tty.tcgetattr(self.STDIN_FILENO)
termios.error: (25, 'Inappropriate ioctl for device')

I see a similar issue was reported with "pipenv run" in https://github.com/pypa/pipenv/issues/290

Is there a way to handle the scenario where a specified version of python doesn't exist in a headless environment? And if no, can "pipenv install" also be modified to use the --no-interactive flag?

Status Needs More Information Type

Most helpful comment

I think it's strange that pipenv can't handle non-interactive environments by default. Poetry can.

But when I run pipenv run lint in GitLab CI it just hangs there forever, without even invoking shell.

$ pipenv run lint
Creating a virtualenv for this project…
Pipfile: /builds/***/***/Pipfile
Using /usr/bin/python3 (3.7.1) to create virtualenv…

Edit: Using something like gitlab-ci with docker executors. So I guess inside a python:3.7 docker image, where no interactive mode exists

All 3 comments

Hey @nfplatzke,

We did a quick check and this issue looks very darn similar to

This could be a coincidence, but if any of these issues solves your problem then I did a good job :smile:

If not, the maintainers will get to this issue shortly.

Cheers,
Your Friendly Neighborhood ProBot

It's going to be very hard to provide insight if you don't fill out the full issue template.

For example, what OS is this? What version of pipenv is it? Do you have pyenv installed? Is it on your path? How do I reproduce this? What command was running when you saw this error?

The thing that is failing has nothing to do with installing pyenv, you are attempting to run pipenv shell in your CI system. You can't make a subshell in a headless CI system where there is no TTY to start off with. This is probably something we could sort out, but it's not very high priority because it's completely unnecessary to work from within a subshell.

I'd love to help you troubleshoot but you need to take a few steps back on this and start at the beginning. What are you trying to _do_ with this setup, what does the setup _look like_, and what have you tried already? FYI I am not aware of a --no-interactive flag in pipenv, which means it hasn't existed in a very, very long time (I did check the history file which is our old changelog and it tells me it was introduced in version 3.4, so probably right around 2 years ago, just when pipenv was first released).

You may have success using PIPENV_YES=1 as an environment variable.

I think it's strange that pipenv can't handle non-interactive environments by default. Poetry can.

But when I run pipenv run lint in GitLab CI it just hangs there forever, without even invoking shell.

$ pipenv run lint
Creating a virtualenv for this project…
Pipfile: /builds/***/***/Pipfile
Using /usr/bin/python3 (3.7.1) to create virtualenv…

Edit: Using something like gitlab-ci with docker executors. So I guess inside a python:3.7 docker image, where no interactive mode exists

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jacek-jablonski picture jacek-jablonski  Â·  3Comments

FooBarQuaxx picture FooBarQuaxx  Â·  3Comments

bgjelstrup picture bgjelstrup  Â·  3Comments

jerzyk picture jerzyk  Â·  3Comments

jacebrowning picture jacebrowning  Â·  3Comments