question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[IndexError] List index out of range when doing poetry install with Docker

See original GitHub issue
  • I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

Issue

Good day, I would like to report an issue using Poetry. I wanted to use Docker as the virtual machine and Poetry as a package manager yet when I execute poetry install

It returns me this stacktrace:

list index out of range

Exception trace:
 /usr/local/lib/python3.7/site-packages/cleo/application.py in run() at line 94
   status_code = self.do_run(input_, output_)
 /usr/local/lib/python3.7/site-packages/poetry/console/application.py in do_run() at line 88
   return super(Application, self).do_run(i, o)
 /usr/local/lib/python3.7/site-packages/cleo/application.py in do_run() at line 197
   status_code = command.run(input_, output_)
 /usr/local/lib/python3.7/site-packages/poetry/console/commands/command.py in run() at line 77
   return super(BaseCommand, self).run(i, o)
 /usr/local/lib/python3.7/site-packages/cleo/commands/base_command.py in run() at line 146
   status_code = self.execute(input_, output_)
 /usr/local/lib/python3.7/site-packages/cleo/commands/command.py in execute() at line 107
   return self.handle()
 /usr/local/lib/python3.7/site-packages/poetry/console/commands/install.py in handle() at line 77
   builder.build()
 /usr/local/lib/python3.7/site-packages/poetry/masonry/builders/editable.py in build() at line 17
   return self._setup_build()
 /usr/local/lib/python3.7/site-packages/poetry/masonry/builders/editable.py in _setup_build() at line 30
   f.write(decode(builder.build_setup()))
 /usr/local/lib/python3.7/site-packages/poetry/masonry/builders/sdist.py in build_setup() at line 114
   pkg_dir, _packages, _package_data = self.find_packages(include)
 /usr/local/lib/python3.7/site-packages/poetry/masonry/builders/sdist.py in find_packages() at line 199
   base = str(include.elements[0].parent)

install [--no-dev] [--dry-run] [-E|--extras EXTRAS] [--develop DEVELOP]

This is the pyproject.toml

name = "app"
version = "0.1.0"
description = "###"
authors = ["exAuth <exampleauthor@email.com>"]

[tool.poetry.dependencies]
python = "^3.7"
django = "^2.2.3"
requests = "^2.22"

[tool.poetry.dev-dependencies]

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"

This is my Dockerfile and docker-compose if it helps: Dockerfile

FROM python:3.7

ENV PYTHONUNBUFFERED 1

RUN mkdir app
COPY . /app
WORKDIR /app
RUN pip install poetry
RUN poetry install -vvv

RUN adduser -D user 
USER user

docker-compose


services:
  app:
    restart: always
    build: .
    expose:
      - "8020"
    ports:
      - 8000:8020
    volumes:
      - ./appname:/app/appname
    working_dir: /app/appname
    command: >
      sh -c "python manage.py runserver 0.0.0.0:8000"

  mongo:
    image: mongo
    restart: always
    environment:
      MONGO_INITDB_ROOT_USERNAME: #####
      MONGO_INITDB_ROOT_PASSWORD: #####
  
  mongo-express:
    image: mongo-express
    restart: always
    ports:
      - 8081:8081
    environment:
      ME_CONFIG_MONGODB_ADMINUSERNAME: #####
      ME_CONFIG_MONGODB_ADMINPASSWORD: #####

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:3
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
autoferritcommented, Apr 23, 2020

I have a solution for now, that I posted in #2139 . I will post it here as well since this issue came up first for me.

I have the same issue. for me I believe it is because of this portion of my pyproject.toml

packages = [
    { include = "bohemian", from = "src"}
]

I am mostly doing this, because my project is inside a src directory. This happens in CI when I add the pyproject.toml and poetry.lock into a container and run install, when my apps code isnt there yet. But it work when I install with

poetry install --no-root

and then don’t install or run poetry build until I add my code into the repo.

3reactions
ephescommented, Jan 23, 2020

I ran in to this error, because I typed packages = [{ include = “./commands” }] instead of packages = [{ include = “./commands.py” }] pretty misleading error message.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python Poetry Index Error – list index out of range
toml file are present. (I mostly got this error while building on Docker when forgetting to add them all in the Dockerfile ....
Read more >
Running Poetry install command gives error : list index out of ...
I am trying to run a python project, for that, I need to install the dependencies I am using poetry ...
Read more >
[Example code]-IndexError: list index out of range, python3
The problem I try to solve is this: "Given an array of integers, find the pair of adjacent elements that has the largest...
Read more >
Python in VSCode: Running and Debugging
Since it's complaining about the list index being out of range, let's inspect the sys.argv list more closely!
Read more >
Dockerizing Python Poetry Applications | by Harpal Sahota
Being a relatively new tool, there isn't much documentation out there regarding dockerizing an application using Poetry.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found