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

Unable to run single python script by pipenv during docker build #1391

Closed
jacek-jablonski opened this issue Feb 2, 2018 · 3 comments
Closed

Comments

@jacek-jablonski
Copy link

Using pipenv run directory/somescript.py causees pipenv to fail, because it looks for directory/somescript.py in PATH

Describe your environment
  1. OS Type Ubuntu
  2. Python version: $ python -V python 3.6
  3. Pipenv version: $ pipenv --version master
Expected result

pipenv runs script using created virtualn environment

Actual result

Step 26/29 : RUN ls $PROJECT_PATH | grep setup.py
---> Running in 7811236ec5ee
setup.py
Removing intermediate container 7811236ec5ee
---> ba280fab02c3
Step 27/29 : RUN pipenv run $PROJECT_PATH/setup.py develop
---> Running in b48df28fbe12
Error: the command /opt/project/setup.py could not be found within PATH.

Steps to replicate

extract from dockerfile:
RUN ls $PROJECT_PATH | grep setup.py
RUN pipenv run $PROJECT_PATH/setup.py develop

@jacek-jablonski
Copy link
Author

And changing Dockerfile to:

ENV SHELL=/bin/bash
RUN pipenv shell -c "$PROJECT_PATH/setup.py develop; exit $?"

results in

Spawning environment shell (/bin/bash). Use 'exit' to leave.
Traceback (most recent call last):
  File "/usr/local/bin/pipenv", line 11, in <module>
    load_entry_point('pipenv==9.0.3', 'console_scripts', 'pipenv')()
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/pipenv/cli.py", line 2204, in shell
    do_shell(three=three, python=python, fancy=fancy, shell_args=shell_args)
  File "/usr/local/lib/python3.6/site-packages/pipenv/cli.py", line 2167, in do_shell
    c.interact(escape_character=None)
  File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/pexpect/pty_spawn.py", line 744, in interact
    mode = tty.tcgetattr(self.STDIN_FILENO)
termios.error: (25, 'Inappropriate ioctl for device')

@sobolevn
Copy link
Contributor

sobolevn commented Feb 2, 2018

I guess you can probably achieve the same with: pipenv run python -c "import this" (just replace import this with your logic).

@nateprewitt
Copy link
Sponsor Member

@JacekJab you can’t run pipenv shell inside of Docker due to it not supporting sub shells as noted in the stacktrace. pipenv run is intended for scripts/applications installed on the path with a shebang specifying how they should be used.

In your case I believe what you’re looking for is pipenv run python somescript.py or add a shebang to the top of the script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants