Why is Elastic beanstalk app creation failing at [InstallDependency] python3.8
I've rebuilt the requirements.txt multiple times, and removed and re-created pipenv, but still every time I build the deployment package for elastic beanstalk, the deployment fails giving this error:
2021/12/14 18:31:40.411896 [ERROR] An error occurred during execution of command [app-deploy] - [InstallDependency]. Stop running the command. Error: fail to install dependencies with Pipfile file with error Command /bin/sh -c /usr/bin/python3.8 -m pipenv install --skip-lock failed with error exit status 1. Stderr:Warning: Your Pipfile requires python_version 3.8, but you are using unknown (/var/app/s/.venv/bin/python).
$ pipenv --rm and rebuilding the virtual environment may resolve the issue.
$ pipenv check will surely fail.
Error while executing command /var/app/staging/.venv/bin/python -c import sysconfig, distutils.sysconfig, io, json, sys; paths = {u'purelib': u'{0}'.format(distutils.sysconfig.get_python_lib(plat_specific=0)),u'stdlib': u'{0}'.format(sysconfig.get_path('stdlib')),u'platlib': u'{0}'.format(distutils.sysconfig.get_python_lib(plat_specific=1)),u'platstdlib': u'{0}'.format(sysconfig.get_path('platstdlib')),u'include': u'{0}'.format(distutils.sysconfig.get_python_inc(plat_specific=0)),u'platinclude': u'{0}'.format(distutils.sysconfig.get_python_inc(plat_specific=1)),u'scripts': u'{0}'.format(sysconfig.get_path('scripts')),u'py_version_short': u'{0}'.format(distutils.sysconfig.get_python_version()), }; value = u'{0}'.format(json.dumps(paths));fh = io.open('/tmp/tmpn2omzq7a.json', 'w'); fh.write(value); fh.close():Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/pipenv/vendor/vistir/misc.py", line 513, in _create_subprocess
c = _spawn_subprocess(
File "/usr/local/lib/python3.8/site-packages/pipenv/vendor/vistir/misc.py", line 190, in _spawn_subprocess
return subprocess.Popen(cmd, **options)
File "/usr/lib64/python3.8/subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib64/python3.8/subprocess.py", line 1702, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: '/var/app/staging/.venv/bin/python'
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/pipenv/vendor/vistir/contextmanagers.py", line 205, in spinner
yield _spinner
File "/usr/local/lib/python3.8/site-packages/pipenv/vendor/vistir/misc.py", line 618, in run
return _create_subprocess(
File "/usr/local/lib/python3.8/site-packages/pipenv/vendor/vistir/misc.py", line 524, in _create_subprocess
raise exc
File "/usr/local/lib/python3.8/site-packages/pipenv/vendor/vistir/misc.py", line 513, in _create_subprocess
c = _spawn_subprocess(
File "/usr/local/lib/python3.8/site-packages/pipenv/vendor/vistir/misc.py", line 190, in _spawn_subprocess
return subprocess.Popen(cmd, **options)
File "/usr/lib64/python3.8/subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib64/python3.8/subprocess.py", line 1702, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: '/var/app/staging/.venv/bin/python'
[KTraceback (most recent call last):
File "/usr/lib64/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib64/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/usr/local/lib/python3.8/site-packages/pipenv/__main__.py", line 5, in <module>
cli()
File "/usr/local/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/usr/local/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/usr/local/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/pipenv/vendor/click/decorators.py", line 73, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/pipenv/vendor/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/pipenv/vendor/click/decorators.py", line 21, in new_func
return f(get_current_context(), *args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/pipenv/cli/command.py", line 232, in install
retcode = do_install(
File "/usr/local/lib/python3.8/site-packages/pipenv/core.py", line 2052, in do_install
do_init(
File "/usr/local/lib/python3.8/site-packages/pipenv/core.py", line 1305, in do_init
do_install_dependencies(
File "/usr/local/lib/python3.8/site-packages/pipenv/core.py", line 870, in do_install_dependencies
batch_install(
File "/usr/local/lib/python3.8/site-packages/pipenv/core.py", line 734, in batch_install
deps_to_install = [
File "/usr/local/lib/python3.8/site-packages/pipenv/core.py", line 735, in <listcomp>
dep for dep in deps_to_install if not project.environment.is_satisfied(dep)
File "/usr/local/lib/python3.8/site-packages/pipenv/project.py", line 376, in environment
self._environment = self.get_environment(allow_global=allow_global)
File "/usr/local/lib/python3.8/site-packages/pipenv/project.py", line 360, in get_environment
environment = Environment(
File "/usr/local/lib/python3.8/site-packages/pipenv/environment.py", line 73, in __init__
self._base_paths = self.get_paths()
File "/usr/local/lib/python3.8/site-packages/pipenv/environment.py", line 364, in get_paths
c = vistir.misc.run(
File "/usr/local/lib/python3.8/site-packages/pipenv/vendor/vistir/misc.py", line 618, in run
return _create_subprocess(
File "/usr/local/lib/python3.8/site-packages/pipenv/vendor/vistir/misc.py", line 524, in _create_subprocess
raise exc
File "/usr/local/lib/python3.8/site-packages/pipenv/vendor/vistir/misc.py", line 513, in _create_subprocess
c = _spawn_subprocess(
File "/usr/local/lib/python3.8/site-packages/pipenv/vendor/vistir/misc.py", line 190, in _spawn_subprocess
return subprocess.Popen(cmd, **options)
File "/usr/lib64/python3.8/subprocess.py", line 854, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib64/python3.8/subprocess.py", line 1702, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: '/var/app/staging/.venv/bin/python'
I've worked throuh issues with my ebextensions and I'm sure that the python version in the local venv is 3.8, all libs are installed correctly, and the code is working locally.