Docker Alpine Python
-> https://github.com/docker-library/python/blob/1d59eb2dd813c64891bf554a8ea01754aba25816/3.6/alpine3.6/DockerfilePython 3.6.3
pipenv, version 8.3.1
If I set PIP_PYTHON_PATH it's ignored and overrided by pipenv (my question is why, what's reasoning behind that?) because https://github.com/kennethreitz/pipenv/blob/master/pipenv/utils.py#L367 It's overriding this ENV variable when I use flag --system
. I've catched that issue because when building my docker image it was failing on pipenv install --system
Why I know this? Because there is other function that works incorrectly.
```(Pdb) python_path
'/bin/python'
(Pdb) which('python')
'/bin/python'
(Pdb) print(sys.executable)
'/usr/local/bin/python'
/ # /bin/python
sh: /bin/python: not found
I think issue is somewhere here: https://github.com/kennethreitz/pipenv/blob/1bf6f5101a3bf1dca78be814e742411cc5bdb2dd/pipenv/cli.py#L1440
p = os.sep.join([location] + ['bin/{0}'.format(command)])
``
this should return
/usr/local/bin/pythonbut for some strange reason it's returning
/bin/python`
pipenv install --system
should install not failed that /bin/python is not found.
pipenv install --system
on that docker image will fail
@galuszkak this is interesting. So sys.executable
is set according to pdb, but we arenāt passing the fact that you used āsystem
when we actually call which()
, so itās trying to use the project virtualenv location which presumably doesnāt exist. This is the relevant invocation which should be easy enough to fix when I get into the office: https://github.com/kennethreitz/pipenv/blob/master/pipenv/utils.py#L406
As for why we are doing all of this, itās mainly so that we can trick the pip-fools package resolver to resolve python packages for versions of python that are different from the active interpreter
Using this Dockerifle, which is based on the one commited to this repo I cannot reproduce this issue, not saying it doesn't exist, looks like something is up, buy this dockerfile seems to work:
FROM python:alpine3.6
# -- Install Pipenv:
RUN set -ex && pip install pipenv --upgrade
# -- Install Application into container:
RUN set -ex && mkdir /app
WORKDIR /app
# -- Adding Pipfiles
ONBUILD COPY Pipfile Pipfile
ONBUILD COPY Pipfile.lock Pipfile.lock
# -- Install dependencies:
ONBUILD RUN set -ex && pipenv install --deploy --system
@erinxocon I didn't use --deploy flag + You aren't using $PIP_PYTHON_PATH which is original issue here which is overriden by pipenv.
@galuszkak Apologies; I understand that, I guess I am unsure why this needs to be set in this case. We should definitely address this bug and fix it. I'm just wondering if there is more going on with docker alpine which required the PIP_PYTHON_PATH being set.
@erinxocon nothing to apologise :), thanks for looking to my issue š . The fix that I supply in #1005 is working for me right now.
But I tried your image and it's working perfectly fine with same set of things. Trying to naildown what is causing my problem in first place, because sam Pipfile and Pipfile.lock and same .env file sounds work on Your Dockerfile, and I don't see a difference because I source same image...
Got it @erinxocon ! Here is how can You reproduce that:
FROM python:3.6-alpine3.6
RUN set -ex && pip install pipenv --upgrade
RUN set -ex && mkdir /app
ENV PIP_PYTHON_PATH=/usr/local/bin/python
COPY Pipfile /app/Pipfile
WORKDIR /app
Pipfile:
[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"
[packages]
flask = "*"
"flask-restful" = "*"
[dev-packages]
pytest = "*"
"pytest-flask" = "*"
[requires]
python_version = "3.6"
$ docker build . -t 'pipenv_issue:latest' --no-cache
$ docker run -it pipenv_issue:latest sh
/app # pipenv install --system
CRITICAL:pip.utils:Error [Errno 2] No such file or directory: '/bin/python': '/bin/python' while executing command python setup.py egg_info
Traceback (most recent call last):
File "/usr/local/bin/pipenv", line 11, in <module>
sys.exit(cli())
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 1855, in install
do_init(dev=dev, allow_global=system, ignore_pipfile=ignore_pipfile, system=system, skip_lock=skip_lock, verbose=verbose, concurrent=concurrent, deploy=deploy, pre=pre)
File "/usr/local/lib/python3.6/site-packages/pipenv/cli.py", line 1320, in do_init
do_lock(system=system, pre=pre)
File "/usr/local/lib/python3.6/site-packages/pipenv/cli.py", line 1050, in do_lock
pre=pre
File "/usr/local/lib/python3.6/site-packages/pipenv/utils.py", line 459, in resolve_deps
resolved_tree.update(resolver.resolve(max_rounds=PIPENV_MAX_ROUNDS))
File "/usr/local/lib/python3.6/site-packages/pipenv/patched/piptools/resolver.py", line 102, in resolve
has_changed, best_matches = self._resolve_one_round()
File "/usr/local/lib/python3.6/site-packages/pipenv/patched/piptools/resolver.py", line 200, in _resolve_one_round
for dep in self._iter_dependencies(best_match):
File "/usr/local/lib/python3.6/site-packages/pipenv/patched/piptools/resolver.py", line 296, in _iter_dependencies
dependencies = self.repository.get_dependencies(ireq)
File "/usr/local/lib/python3.6/site-packages/pipenv/patched/piptools/repositories/pypi.py", line 153, in get_dependencies
result = reqset._prepare_file(self.finder, ireq)
File "/usr/local/lib/python3.6/site-packages/pipenv/patched/pip/req/req_set.py", line 639, in _prepare_file
abstract_dist.prep_for_dist()
File "/usr/local/lib/python3.6/site-packages/pipenv/patched/pip/req/req_set.py", line 134, in prep_for_dist
self.req_to_install.run_egg_info()
File "/usr/local/lib/python3.6/site-packages/pipenv/patched/pip/req/req_install.py", line 438, in run_egg_info
command_desc='python setup.py egg_info')
File "/usr/local/lib/python3.6/site-packages/pipenv/patched/pip/utils/__init__.py", line 667, in call_subprocess
cwd=cwd, env=env)
File "/usr/local/lib/python3.6/subprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "/usr/local/lib/python3.6/subprocess.py", line 1344, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/bin/python': '/bin/python'
Seems to be a problem with using ONBUILD RUN vs just RUN. Not being a docker expert I'll have to figure out what the difference is between them.
@erinxocon I don't think that's the problem. In example above I show You problem inside running container not on any step building image.
@erinxocon the problem is with setting the variable in the first place (which doesn't actually need to be set but that's beside the point) -- by setting PIP_PYTHON_PATH
it breaks resolver functionality when you need to pass --system
:
def which(command, location=None, allow_global=False):
if location is None:
location = project.virtualenv_location
if not allow_global:
if os.name == 'nt':
p = find_windows_executable(os.path.join(location, 'Scripts'), command)
else:
p = os.sep.join([location] + ['bin/{0}'.format(command)])
else:
if command == 'python':
p = sys.executable
return p
Since @galuszkak is using --system
but allow_global
doesn't get passed through by the copy of which
that is passed to the resolver, but there is also no Project.virtualenv_location
due to the --system
flag, we wind up having simultaneously:
location
is None
Project.virtualenv_location
is None
(location
is still None
)allow_global
p = os.sep.join([None] + ['bin/{0}'.format(python)])
That's how we wind up with /bin/python
as a command attempt.
@galuszkak Apologies I didn't see the -it sh flag passed in your example.
@techalchemy makes sense. Do you have a patch in the works, or should I take that on?
@erinxocon @galuszkak already wrote a patch (#1005) which @nateprewitt had expressed some concerns about but I'm not sure where that leaves it
@erinxocon again, nothing to apologies and really thanks for looking into my issue.
Can we agree/disagree on #1005 as a fix? I will try move discussion further on that PR.
This issue hit me again today, but on OS X in totally different conditions. Stack trace below.
ā saudi git:(dev) ā pipenv install -r requirements.txt
Warning: the environment variable LANG is not set!
We recommend setting this in ~/.profile (or equivalent) for proper expected behavior.
Creating a virtualenv for this projectā¦
ā Traceback (most recent call last):
File "/usr/local/bin/pew", line 7, in <module>
from pew.pew import pew
File "/usr/local/lib/python3.6/site-packages/pew/__init__.py", line 11, in <module>
from . import pew
File "/usr/local/lib/python3.6/site-packages/pew/pew.py", line 42, in <module>
from pew._utils import (check_call, invoke, expandpath, own, env_bin_dir,
File "/usr/local/lib/python3.6/site-packages/pew/_utils.py", line 22, in <module>
encoding = locale.getlocale()[1] or 'ascii'
File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/locale.py", line 581, in getlocale
return _parse_localename(localename)
File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/locale.py", line 490, in _parse_localename
raise ValueError('unknown locale: %s' % localename)
ValueError: unknown locale: UTF-8
Virtualenv location:
Requirements.txt found, instead of Pipfile! Convertingā¦
Warning: Your Pipfile now contains pinned versions, if your requirements.txt did.
We recommend updating your Pipfile to specify the "*" version, instead.
Requirements file provided! Importing into Pipfileā¦
Creating a virtualenv for this projectā¦
ā Traceback (most recent call last):
File "/usr/local/bin/pew", line 7, in <module>
from pew.pew import pew
File "/usr/local/lib/python3.6/site-packages/pew/__init__.py", line 11, in <module>
from . import pew
File "/usr/local/lib/python3.6/site-packages/pew/pew.py", line 42, in <module>
from pew._utils import (check_call, invoke, expandpath, own, env_bin_dir,
File "/usr/local/lib/python3.6/site-packages/pew/_utils.py", line 22, in <module>
encoding = locale.getlocale()[1] or 'ascii'
File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/locale.py", line 581, in getlocale
return _parse_localename(localename)
File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/locale.py", line 490, in _parse_localename
raise ValueError('unknown locale: %s' % localename)
ValueError: unknown locale: UTF-8
Virtualenv location:
Pipfile.lock not found, creatingā¦
Locking [dev-packages] dependenciesā¦
Locking [packages] dependenciesā¦
CRITICAL:pip.utils:Error [Errno 2] No such file or directory: '/bin/python': '/bin/python' while executing command python setup.py egg_info
Traceback (most recent call last):
File "/usr/local/bin/pipenv", line 11, in <module>
sys.exit(cli())
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 1866, in install
do_init(dev=dev, allow_global=system, ignore_pipfile=ignore_pipfile, system=system, skip_lock=skip_lock, verbose=verbose, concurrent=concurrent, deploy=deploy, pre=pre)
File "/usr/local/lib/python3.6/site-packages/pipenv/cli.py", line 1330, in do_init
do_lock(system=system, pre=pre)
File "/usr/local/lib/python3.6/site-packages/pipenv/cli.py", line 1121, in do_lock
pre=pre
File "/usr/local/lib/python3.6/site-packages/pipenv/utils.py", line 461, in resolve_deps
resolved_tree.update(resolver.resolve(max_rounds=PIPENV_MAX_ROUNDS))
File "/usr/local/lib/python3.6/site-packages/pipenv/patched/piptools/resolver.py", line 102, in resolve
has_changed, best_matches = self._resolve_one_round()
File "/usr/local/lib/python3.6/site-packages/pipenv/patched/piptools/resolver.py", line 200, in _resolve_one_round
for dep in self._iter_dependencies(best_match):
File "/usr/local/lib/python3.6/site-packages/pipenv/patched/piptools/resolver.py", line 274, in _iter_dependencies
for dependency in self.repository.get_dependencies(ireq):
File "/usr/local/lib/python3.6/site-packages/pipenv/patched/piptools/repositories/pypi.py", line 153, in get_dependencies
result = reqset._prepare_file(self.finder, ireq)
File "/usr/local/lib/python3.6/site-packages/pipenv/patched/pip/req/req_set.py", line 523, in _prepare_file
abstract_dist.prep_for_dist()
File "/usr/local/lib/python3.6/site-packages/pipenv/patched/pip/req/req_set.py", line 134, in prep_for_dist
self.req_to_install.run_egg_info()
File "/usr/local/lib/python3.6/site-packages/pipenv/patched/pip/req/req_install.py", line 438, in run_egg_info
command_desc='python setup.py egg_info')
File "/usr/local/lib/python3.6/site-packages/pipenv/patched/pip/utils/__init__.py", line 667, in call_subprocess
cwd=cwd, env=env)
File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 1344, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/bin/python': '/bin/python'
My shell was ZSH. After setting LC_ALL and LANG in .zshrc everything works fine. But I'm not sure why LANG/LC_ALL should have any impact on choosing python interpreter.
@galuszkak it is specifically an issue on Mac because of locale issues, I'll try to remember tomorrow to track down an early issue in this project where Kenneth discussed the problem with the default shell config but basically if your locale isn't set right python dies horribly
As for the PR I think we needed nate to sign off, let me ping him over in the PR
Pass system
to the function, where which
is being passed, and pass it to the passed which
.
@kennethreitz issue is not resolved, can You don't close things that aren't fixed yet. Issue is still reproducible.
no movement in 30 days. it'll come back up if its important
I'm with this problem on alpine images. Any solution?
Step 7/7 : RUN pipenv install --dev --system --verbose
---> Running in a3097251c098
Pipfile.lock (1b4750) out of date, updating to (6a9e01)ā¦
Locking [dev-packages] dependenciesā¦
Locking [packages] dependenciesā¦
CRITICAL:pip.utils:Error [Errno 2] No such file or directory: '/bin/python': '/bin/python' while executing command python setup.py egg_info
Traceback (most recent call last):
File "/usr/local/bin/pipenv", line 11, in <module>
sys.exit(cli())
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 1866, in install
do_init(dev=dev, allow_global=system, ignore_pipfile=ignore_pipfile, system=system, skip_lock=skip_lock, verbose=verbose, concurrent=concurrent, deploy=deploy, pre=pre)
File "/usr/local/lib/python3.6/site-packages/pipenv/cli.py", line 1325, in do_init
do_lock(system=system, pre=pre)
File "/usr/local/lib/python3.6/site-packages/pipenv/cli.py", line 1121, in do_lock
pre=pre
File "/usr/local/lib/python3.6/site-packages/pipenv/utils.py", line 461, in resolve_deps
resolved_tree.update(resolver.resolve(max_rounds=PIPENV_MAX_ROUNDS))
File "/usr/local/lib/python3.6/site-packages/pipenv/patched/piptools/resolver.py", line 102, in resolve
has_changed, best_matches = self._resolve_one_round()
File "/usr/local/lib/python3.6/site-packages/pipenv/patched/piptools/resolver.py", line 200, in _resolve_one_round
for dep in self._iter_dependencies(best_match):
File "/usr/local/lib/python3.6/site-packages/pipenv/patched/piptools/resolver.py", line 296, in _iter_dependencies
dependencies = self.repository.get_dependencies(ireq)
File "/usr/local/lib/python3.6/site-packages/pipenv/patched/piptools/repositories/pypi.py", line 153, in get_dependencies
result = reqset._prepare_file(self.finder, ireq)
File "/usr/local/lib/python3.6/site-packages/pipenv/patched/pip/req/req_set.py", line 639, in _prepare_file
abstract_dist.prep_for_dist()
File "/usr/local/lib/python3.6/site-packages/pipenv/patched/pip/req/req_set.py", line 134, in prep_for_dist
self.req_to_install.run_egg_info()
File "/usr/local/lib/python3.6/site-packages/pipenv/patched/pip/req/req_install.py", line 438, in run_egg_info
command_desc='python setup.py egg_info')
File "/usr/local/lib/python3.6/site-packages/pipenv/patched/pip/utils/__init__.py", line 667, in call_subprocess
cwd=cwd, env=env)
File "/usr/local/lib/python3.6/subprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "/usr/local/lib/python3.6/subprocess.py", line 1344, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '/bin/python': '/bin/python'
This will be resolved by #1097 if and when it is merged
@kennethreitz issue has 23 days now not 30 days, so You closed it too quickly. Also there is pending PR after first one was closed. So there is still pending action on this issue...
Please reopen issue.
I can reproduce this in the latest release (9.0.1), please reopen.
@jacebrowning thanks for the report but this wasn't fixed in 9.0.1, #1005 wasn't merged until after 9.0.1 was released. Try with master and see if it is resolved
I just tried, pip install git+git://github.com/pypa/pipenv.git@master
and pipenv install --dev --system
started working in my python:3.6.3
docker image. Can another release be made?
I can repro the problem in master. Although it is closed, the PR #1097 that suppose to solve this problem didn't actually get merged into master. Please reopen
Hi, i just found this issue today, is there another way of using Pipenv in an alpine container?
@LuRsT I just install via the git commit sha, which has the fix.
Currently waiting for a new release.
RUN set -ex && pip install git+git://github.com/pypa/pipenv.git@8378a1b104f2d817790a05da370bef0a1b00f452
EDIT: you will need to install git for this to work.
Cool, thanks @sbdchd!
Unfortunately I'm still running into this in both python:3.6.3
and ubuntu:17.10
containers, with all versions of pipenv mentioned here, including the one suggested by @sbdchd .
Edit: Sorry that was a little unhelpful. I wasn't able to recreate it with a more minimal Dockerfile, so it must be something specific (and probably stupid) I'm doing. I'll report back if I find it!
Here is the Dockerfile I am using for dev:
FROM python:3.6
ENV PYTHONUNBUFFERD 1
RUN apt-get update
RUN apt-get install netcat -y
# -- Install Pipenv:
RUN set -ex && pip install git+git://github.com/pypa/pipenv.git@8378a1b104f2d817790a05da370bef0a1b00f452
# -- Install Application into container:
RUN set -ex && mkdir /app
WORKDIR /app
# -- Adding Pipfiles
COPY Pipfile Pipfile
COPY Pipfile.lock Pipfile.lock
# -- Install dependencies:
RUN set -ex && pipenv install --dev --system
WORKDIR /app
VOLUME ["/app"]
Thanks for that. As it turns out, the error in my case was happening when attempting to create a lock file. Am transitioning some projects from requirements.txt
's at the moment so was installing from that in a container while tinkering around. Given that this probably isn't a recommended use-case, it's probably not worth worrying about too much?
I have added a work-around that is pretty simple to use in Docker in #917. The comment is https://github.com/pypa/pipenv/issues/917#issuecomment-375312947. While not ideal, I do think that it is quite simple. @mcgeeco; my scenario was similar to yours for wanting this, so maybe you'll find my work-around useful?
Hi there!
Just got the same issue here with the python:3.6
Docker image and pipenv-11.9.0
.
Here's a Dockerfile sample:
FROM python:3.6
WORKDIR /app
COPY . /app/
RUN pip install pipenv
RUN pipenv install --system
EXPOSE 8000
CMD ["python", "main.py"]
For now, I'm using @Jitsusama work-around.
Thanks.
Same here, still being hit by this.
Sorry for the ongoing trouble here folks, we had some trouble with our testing infrastructure but we will get this looked at
Hi, I am using the latest version of the library 11.10.0 and still seeing this issue. The base image is ubuntu:xenial.
Step 12/22 : COPY Pipfile /tmp/
---> Using cache
---> 416d6b4f86bf
Step 13/22 : COPY Pipfile.lock.master /tmp/Pipefile.lock
---> 40a28443be72
Step 14/22 : RUN cd /tmp && pip3.6 install pipenv==11.10.0
---> Running in 883b8a638d52
Collecting pipenv==11.10.0
Downloading https://XYZ/api/pypi/pypi/packages/e5/fd/740a41c68c38262265d73191fb686f38d26c4ea1ea6080a65b2b626bedc7/pipenv-11.10.0-py3-none-any.whl (5.6MB)
Collecting virtualenv-clone>=0.2.5 (from pipenv==11.10.0)
Downloading https://XYZ/api/pypi/pypi/packages/6d/c2/dccb5ccf599e0c5d1eea6acbd058af7a71384f9740179db67a9182a24798/virtualenv_clone-0.3.0-py2.py3-none-any.whl
Requirement already satisfied: setuptools>=36.2.1 in /usr/local/lib/python3.6/site-packages (from pipenv==11.10.0)
Collecting certifi (from pipenv==11.10.0)
Downloading https://XYZ/api/pypi/pypi/packages/fa/53/0a5562e2b96749e99a3d55d8c7df91c9e4d8c39a9da1f1a49ac9e4f4b39f/certifi-2018.1.18-py2.py3-none-any.whl (151kB)
Requirement already satisfied: pip>=9.0.1 in /usr/local/lib/python3.6/site-packages (from pipenv==11.10.0)
Collecting virtualenv (from pipenv==11.10.0)
Downloading https://XYZ/api/pypi/pypi/packages/ed/ea/e20b5cbebf45d3096e8138ab74eda139595d827677f38e9dd543e6015bdf/virtualenv-15.2.0-py2.py3-none-any.whl (2.6MB)
Installing collected packages: virtualenv-clone, certifi, virtualenv, pipenv
Successfully installed certifi-2018.1.18 pipenv-11.10.0 virtualenv-15.2.0 virtualenv-clone-0.3.0
---> c9e452fdc262
Removing intermediate container 883b8a638d52
Step 15/22 : RUN set -ex && pipenv install --dev --system
---> Running in 8c23d30ef730
+ pipenv install --dev --system
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/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 366, in install
selective_upgrade=selective_upgrade,
File "/usr/local/lib/python3.6/site-packages/pipenv/core.py", line 1730, in do_install
skip_requirements=skip_requirements,
File "/usr/local/lib/python3.6/site-packages/pipenv/core.py", line 634, in ensure_project
ensure_pipfile(validate=validate, skip_requirements=skip_requirements)
File "/usr/local/lib/python3.6/site-packages/pipenv/core.py", line 288, in ensure_pipfile
project.create_pipfile(python=python)
File "/usr/local/lib/python3.6/site-packages/pipenv/project.py", line 557, in create_pipfile
config_parser = ConfigOptionParser(name=self.name)
File "/usr/local/lib/python3.6/site-packages/pipenv/vendor/pip9/baseparser.py", line 149, in __init__
assert self.name
AssertionError
The command '/bin/sh -c set -ex && pipenv install --dev --system' returned a non-zero code: 1
@Ankitmaroo sorry for the frustration, as a few people mentioned in various places (I know there is a lot to cover on this by now) the critical piece is to make sure you don't just use RUN cd
but that you actually use WORKDIR /somedirectory
because (currently, refactor underway though) pathfinding (and finding python as a result) is somewhat bugged when you try to do it from /
@techalchemy unfortunately, I cannot confirm that. My minimal Dockerfile:
FROM python:3.6-alpine3.7
ENV PYTHONUNBUFFERED=1
WORKDIR app/
COPY Pipfile* app/
RUN set -x \
&& pip install --upgrade pip setuptools wheel pipenv \
&& pipenv install --system --dev
and the error:
+ pipenv install --system --dev
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/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 366, in install
selective_upgrade=selective_upgrade,
File "/usr/local/lib/python3.6/site-packages/pipenv/core.py", line 1730, in do_install
skip_requirements=skip_requirements,
File "/usr/local/lib/python3.6/site-packages/pipenv/core.py", line 634, in ensure_project
ensure_pipfile(validate=validate, skip_requirements=skip_requirements)
File "/usr/local/lib/python3.6/site-packages/pipenv/core.py", line 288, in ensure_pipfile
project.create_pipfile(python=python)
File "/usr/local/lib/python3.6/site-packages/pipenv/project.py", line 585, in create_pipfile
'python_version': python_version(required_python)[: len('2.7')]
TypeError: 'NoneType' object is not subscriptable
which is the same as in #1939.
These are the installed versions:
Successfully installed certifi-2018.1.18 pipenv-11.10.0 virtualenv-15.2.0 virtualenv-clone-0.3.0
If instead I sym-link the python binary everything is fine.
RUN set -x \
&& pip install --upgrade pip setuptools wheel pipenv \
&& ln -sf /usr/local/bin/python /bin/python \
&& pipenv install --system --dev
@Midnighter are you actually copying a pipfile over?
Yes
[[source]]
url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"
[packages]
Flask = "*"
[dev-packages]
pytest = "*"
[requires]
python_version = "3.6"
Agree with @Midnighter. Still, see the same error as above.
@Midnighter you can't set your WORKDIR
to app/
and then COPY Pipfile* app/
-- this moves you into /app
and then copies your Pipfile
into /app/app
which means pipenv
doesn't find a Pipfile to work with. I simply did this and it worked:
FROM python:3.6-alpine3.7
ENV PYTHONUNBUFFERED=1
COPY Pipfile* app/
WORKDIR app/
RUN set -x \
&& pip install --upgrade pip setuptools wheel pipenv \
&& pipenv install --system --dev
What Docker version are you on? You are correct, I made a mistake in simplifying the Dockerfile but neither the version that you posted here nor another version worked for me.
I am on Docker version 17.09.0-ce, build afdb6d4
. When I try your Dockerfile above I get:
+ pipenv install --system --dev
Pipfile.lock not found, creatingā¦
Locking [dev-packages] dependenciesā¦
ython: not found
When I use it as I originally intended.
FROM python:3.6-alpine3.7
ENV PYTHONUNBUFFERED=1
WORKDIR /app
COPY Pipfile* /app/
RUN set -x \
&& pip install --upgrade pip setuptools wheel pipenv \
&& pipenv install --system --dev
I get the same error.
Why is a lock file a requirement for finding the Python executable? Especially since I'm not even using the --deploy
flag there. You're right, though, that it does work with an existing lock file.
@Midnighter because pipenv has to do dependency resolution which means it had to lock unless it has a lockfile. But, if you pass āsystem
it canāt do dependency resolution ā this requires and isolated environment and āsystem
basically says ādonāt make a virtualenvā which is what we would use for isolation. The messaging isnāt great but I have some changes up for this.
Most helpful comment
@kennethreitz issue is not resolved, can You don't close things that aren't fixed yet. Issue is still reproducible.