I am using poetry as a dependency manager for python, and when I'm trying to install the dependencies using poetry:
poetry install
I get this error:
$ poetry install
Installing dependencies from lock file
[AttributeError]
'bool' object has no attribute 'strip'
Any ideas on what possibly can cause this error on happening because It doesn't let the dependencies install...
Example of pyproject.toml
[tool.poetry]
name = "orex"
version = "0.1.0"
description = ""
[tool.poetry.dependencies]
python = "^3.8"
fastapi = ">=0.52.0"
SQLAlchemy = ">=1.3.12"
pydantic = {extras = ["email"], version = "^1.3"}
click = "^7.0"
alembic = "^1.3.2"
uvicorn = "^0.11.1"
passlib = "^1.7.2"
Change
pydantic = {extras = ["email"], version = "^1.3"}
to
pydantic = "{extras = ['email'], version = '^1.3'}"
Related
I'm trying to install pl_cross repository using poetry. In the README it's indicated that it must be installed running python setup.py install. When I try to install the repo adding it to my pyproject.toml file:
[tool.poetry]
name = "iq_segmentator"
version = "0.1.0"
description = "Speed up Deep Learning semantic segmentation projects."
authors = ["Jeremiah Poveda Martínez <jere#qubiotech.com>"]
[tool.poetry.dependencies]
python = "3.9"
wandb = "0.12.18"
nibabel = "4.0.1"
torch = "1.11.0"
pytorch-lightning = "1.6.4"
torchmetrics = "0.9.1"
monai = "0.9.0"
hydra-core = "1.2.0"
black = "22.3.0"
pytest = "7.1.2"
numpy = "1.22.4"
matplotlib = "3.5.2"
pl_cross = {git = "https://github.com/SkafteNicki/pl_cross.git", branch="master"}
sphinx = {version = "5.0.2", optional = true}
sphinxcontrib-napoleon = {version = "0.7", optional = true}
sphinx-rtd-theme = {version = "1.0.0", optional = true}
[tool.poetry.scripts]
pl_cross = "pl_closs:setup"
[tool.poetry.extras]
docs = ["sphinx", "sphinx-rtd-theme", "sphinxcontrib-napoleon"]
[tool.poetry.dev-dependencies]
mlflow = "^1.26.1"
pydra = "^0.18"
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
I get the following error:
Updating dependencies
Resolving dependencies... (4.8s)
PackageInfoError
Unable to determine package info for path: /tmp/pypoetry-git-pl_crossah48_3rm
Fallback egg_info generation failed.
Command ['/tmp/tmpfc8t0g_3/.venv/bin/python', 'setup.py', 'egg_info'] errored with the following return code 1, and output:
Traceback (most recent call last):
File "/tmp/pypoetry-git-pl_crossah48_3rm/setup.py", line 15, in <module>
import pl_cross
File "/tmp/pypoetry-git-pl_crossah48_3rm/pl_cross/__init__.py", line 40, in <module>
from .datamodule import BaseKFoldDataModule, KFoldDataModule
File "/tmp/pypoetry-git-pl_crossah48_3rm/pl_cross/datamodule.py", line 5, in <module>
import torch
ModuleNotFoundError: No module named 'torch'
at ~/.poetry/lib/poetry/inspection/info.py:500 in _pep517_metadata
496│ try:
497│ venv.run_python("setup.py", "egg_info")
498│ return cls.from_metadata(path)
499│ except EnvCommandError as fbe:
→ 500│ raise PackageInfoError(
501│ path, "Fallback egg_info generation failed.", fbe
502│ )
503│ finally:
504│ os.chdir(cwd.as_posix())
NOTE: I have torch installed. Could someone point out what is causing the error? Is is possible to isntall packages this way with poetry? Is this documented?
Poetry is not able to parse the needed metadata (package name, version and dependencies) from the setup.py. This is why a wheel package needs to be build where Poetry can obtain these information.
Building the wheel is done in a clean, temporary environment and all build-dependencies mentioned in the pyproject.toml according to PEP-518 are installed into this.
The problem with pl_cross is, that within the setup.py pl_cross is imported, which in return imports other modules and dependencies, which are not installed in the build environment.
Please contact the maintainer of this project and ask them to refactor it, so that the unnecessary imports doesn't happen.
Short version:
How can I poetry install a package where one of the dependencies is a local tarball/zip file? It doesn't seem to work, yet it is shown in the poetry docs?
I can poetry install the package when the dependency is pulled from gitlab, but the install fails when I manually download the dependency from gitlab as a tarball and try to poetry install with the dependency in the tarball.
Long version:
I am trying to use poetry to install two packages that I have developed:
a base package called my_package
an extension called extension_of_my_package.
Both packages are in private repos in gitlab, and both have a pyproject.toml containing their dependency list. I can successfully poetry install the extended package (extension_of_my_package) when the base package my_package is downloaded from gitlab. i.e. the pyproject.toml file in extension_of_my_package has a tool.poetry.source section that gives the location of the my_package private repo on gitlab.
However, external users cannot access my private repo, so I need to ensure the
packages can be installed from tarballs (that I download from gitlab and give to the client).
To install extension_of_my_package I do this:
tar xzf extension_of_my_package.tgz
cd extension_of_my_package/python
and then edit the pyproject.toml, changing the dependency on my_package to point to
the local tarball:
my_package = { path = "/path/to/my_package.tgz"}
and then run poetry install. This fails with the error message:
> poetry install
Updating dependencies
Resolving dependencies... (9.3s)
TypeError
expected string or bytes-like object
at /home/user/.poetry/lib/poetry/_vendor/py3.8/poetry/core/utils/helpers.py:27 in canonicalize_name
23│ _canonicalize_regex = re.compile(r"[-_]+")
24│
25│
26│ def canonicalize_name(name): # type: (str) -> str
→ 27│ return _canonicalize_regex.sub("-", name).lower()
28│
29│
30│ def module_name(name): # type: (str) -> str
31│ return canonicalize_name(name).replace(".", "_").replace("-", "_")
According to the poetry docs it is possible to install from a local file:
[tool.poetry.dependencies]
# directory
my-package = { path = "../my-package/", develop = false }
# file
my-package = { path = "../my-package/dist/my-package-0.1.0.tar.gz" }
I also tried using my-package = { file = ... instead of my-package = { path = ..., but it didn't work either.
I tried adding a minimal setup.py file to my_package (see this post), but that didn't help.
I tried converting my_package (in tarball format) to a wheel. I can successfully poetry install when my package is in wheel format, but my_packages's dependencies are not installed. I can't see how to include the dependency info in the wheel. When I created the wheel I tried specifying the
dependency info in two ways:
in setup.cfg:
[metadata]
name = my_package
version = 0.1.0
description = My Package
license = Proprietary
[options]
packages = find:
install_requires =
matplotlib >=3.2.0
and
in setup.py"
from setuptools import setup
setup(
name=`my_package`,
version="0.1.0,
packages=['.my_package'],
install_requires=['matplotlib >= 3.2.0',]
)
To rule out any problem with my own package, I created a minimal test and tried to poetry install a publicly available package (tqdm) from its zip file (downloaded from github). It also fails. The pyproject.toml for this minimal test is:
[tool.poetry]
name = "tester"
version = "0.0.1"
description = "test package"
authors = [ "me" ]
packages = [
{ include = "tester" }
]
[tool.poetry.dependencies]
python = ">=3.7,<3.9"
tqdm = {file = "/home/user/tqdm-master.zip"}
and the error message is:
> poetry install
Updating dependencies
Resolving dependencies... (13.0s)
RuntimeError
Unable to determine package info from path: /home/user/tqdm-master.zip
at /home/user/.poetry/lib/poetry/puzzle/provider.py:251 in get_package_from_file
247│ package = PackageInfo.from_path(path=file_path).to_package(
248│ root_dir=file_path
249│ )
250│ except PackageInfoError:
→ 251│ raise RuntimeError(
252│ "Unable to determine package info from path: {}".format(file_path)
253│ )
254│
255│ return package
I am using poetry version 1.1.13.
I am open to any alternative approaches, so long as all the dependencies are checked.
I'm testing out the Natural Language API from Google but this line
from google.cloud import language_v1
is throwing the following error
ModuleNotFoundError: No module named 'google'
I am using Poetry and my pyproject.toml contains google-cloud
[tool.poetry]
name = "cocoon"
version = "0.1.0"
description = ""
authors = ["Your Name <you#example.com>"]
[tool.poetry.dependencies]
python = "^3.9"
pandas = "^1.2.3"
app-store-scraper = "^0.3.5"
google-cloud-language = "^2.0.0"
google-api-python-client = "^2.0.2"
google-cloud = "^0.34.0"
fsspec = "^0.8.7"
[tool.poetry.dev-dependencies]
pytest = "^5.2"
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
What I am following is based on these docs at Google.
There are similar questions (like this or this) but no solution has worked for me so far. I am not using a venv as outlined there since I am using Poetry. I have also double-checked on VSCode that the interpreter is correct.
i'm trying to get certificate on freeCodeCamp by making project on repl.it . Everything goes well until this happened. I don't know what happen, i have search it on google but i still didn't understand. I appreciate for your help
Python 3.8.2 (default, Feb 26 2020, 02:56:10)
>
Repl.it: Updating package configuration
--> python3 -m poetry lock
[RuntimeError]
The Poetry configuration is invalid:
- 'description' is a required property
exit status 1
Repl.it: Package operation failed
Add description="" between [tool.poetry] and [tool.poetry.dependencies]
Example :
[tool]
[tool.poetry]
authors = ["Your Name <you#example.com>"]
description=""
name = "root"
version = "0.0.0"
[tool.poetry.dependencies]
pandas = "*"
python = "^3.7"
seaborn = "*"
I am trying to run poetry install command, but I get the following error:
[EnvCommandError]
Command ['pip', 'install', '-e', '<PROJECT_FOLDER_PATH>'] errored with
the following return code 1, and output:
Obtaining file:///<PROJECT_FOLDER_PATH>
ERROR: Package '<subfolder>' requires a different Python: 3.6.8 not in '>=3.7,<4.0'
Where my project directory containing .toml file is marked as <PROJECT_FOLDER> (PROJECT_FOLDER_PATH is, correspondingly, it's full path), and it contains <subfolder>.
Part of my toml file:
[tool.poetry]
name = "<PROJECT_FOLDER>"
version = "0.1.0"
description = ""
authors = ["Your Name <you#example.com>"]
[tool.poetry.dependencies]
python = "^3.7"
It seems that poetry tries to install the project itself as a dependency, but for some reason that I don't understand it seems the conflicting Python version. I temporarily solved it by setting python = "^3.6", but now the issue is back, as I need some package which only accepts python = "^3.7".