Reputation: 7978
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
Upvotes: 12
Views: 12927
Reputation: 141
For me, I needed a file called myproject.py
. (Could be an empty file.)
Otherwise running poetry install
would throw:
Error: The current project could not be installed: No file/folder found for package myproject
Upvotes: 1
Reputation: 837
For those that will have same error as mine:
rename package-name
to package_name
Upvotes: 3
Reputation: 6442
I got this error by running poetry install
in the monorepo root (which had its own pyproject.toml, but wasn't meant to be installed) instead of the api
folder with my real pyproject.toml.
Upvotes: 0
Reputation: 148
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:
pyproject.toml
orpyproject.toml
file to the correct directory orpackage-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:
Upvotes: 11