John Philip
John Philip

Reputation: 170

Running a python script with poetry

I'm currently in the process of migrating an existing project to use Poetry instead of a requirements.txt file for managing dependencies. I've successfully linked the necessary dependencies, but I'm facing an issue when trying to declare and run scripts, such as starting the server or creating a database. My server file is located at src/main.py within the project structure.

In my pyproject.toml, I've defined a script as follows:

[tool.poetry.scripts]
start = "python src/main.py"

Following the documentation, I've executed poetry install to ensure the dependencies are installed. However, when I try to start my server using poetry run start, I encounter the following error:

Warning: 'start' is an entry point defined in pyproject.toml, but it's not installed as a script. You may get improper `sys.argv[0]`.

The support to run uninstalled scripts will be removed in a future release.

Run `poetry install` to resolve and get rid of this message.

not enough values to unpack (expected 2, got 1)

I'm not sure what I'm doing wrong, and this is my initial experience with Poetry. I'd appreciate any guidance or suggestions to resolve this issue and successfully run my project with Poetry."

Following the documentation, I've executed poetry install to ensure the dependencies are installed. However, when I try to start my server using poetry run start, I encounter the following error:

Upvotes: 2

Views: 1677

Answers (1)

John Philip
John Philip

Reputation: 170

"OK, so Poetry scripts are not meant to be used like npm scripts They are when you create a package that exposes executable entrypoints (for example pytest gives the pytest command, or ansible with ansible and ansible-playbook) [15:44] What you're looking for could be poethepoet (https://github.com/nat-n/poethepoet), but maybe there are others" by @nymous" This is what solved my query.

Upvotes: 5

Related Questions