Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Poetry No File/Folder for Package

I have a simple project layout

myproject on ī‚  main [$!?] is šŸ“¦ v1.0.0 via  v18.14.0 via šŸ v3.10.9 
āÆ tree -L 1
.
ā”œā”€ā”€ build
ā”œā”€ā”€ deploy
ā”œā”€ā”€ Dockerfile
ā”œā”€ā”€ poetry.lock
ā”œā”€ā”€ pyproject.toml
ā”œā”€ā”€ README.md
ā”œā”€ā”€ scripts.py
└── src

The pyproject.toml is:

[tool.poetry]
name = "myproject"
version = "0.1.0"
description = ""
authors = [""]

[tool.poetry.scripts]
test = "scripts:test"

The scripts.py is:

import subprocess

def test():
    """
    Run all unittests.
    
    """
    subprocess.run(
        ['python', '-u', '-m', 'pytest']
    )
if __name__ == '__main__':
    test()

When I run poetry run test:

myproject on main [$!?] is šŸ“¦ v1.0.0 via  v18.14.0 via šŸ v3.10.9


No file/folder found for package myproject
like image 734
gdm Avatar asked Dec 14 '25 10:12

gdm


2 Answers

Short answer:

The directory where your pyproject.toml file sits needs to be share the same name, e.g., if the name config in pyproject.toml is name = "myproject", the directory needs to be also named myproject. Therefore, you must either:

  1. Rename the directory to match your name configuration in the pyproject.toml or
  2. Move the pyproject.toml file to the correct directory or
  3. If you don't care about making your project packageable by Poetry and only use poetry as your package manager for this project, add package-mode = false to your pyproject.toml.

Explanation:

There's a thread on the official GitHub for Poetry that discusses this issue. The gist of the issue is that whatever you choose for your project name, i.e., name = "myproject", needs to be the direct parent directory of where your pyproject.toml file lives. When there is a mismatch, you get the error you are getting.

Sources:

  • Breakdown of the cause of the issue on thread on GitHub
  • A Poetry contributor's response on thread on GitHub
like image 179
wongacj Avatar answered Dec 17 '25 01:12

wongacj


For those that will have same error as mine:

rename package-name to package_name

like image 34
ravenwing Avatar answered Dec 16 '25 23:12

ravenwing



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!