0

After a fair bit of thrashing, I successfully installed the Python Camelot PDF table extraction tool (https://pypi.org/project/camelot-py/) and it works for the intended purpose. But in order to get it to work, aside from having to correct a deprecated dependency (by editing pyproject.toml and setting PyPDF2 =”2.12.1”) I used pip to install Camelot from within a Poetry (my preferred package manager) environment- because I haven’t yet figured out any other way.

Since I’m very new to Python and package management (but not to programming) I have some holes in my basic understanding that I need to patch up. I thought that using two package managers on the same project in principle defeats the purpose of using package managers, so I feel like I’m lucky that it works. Would love some input on what I’m missing.

The documentation for Camelot provides instructions for installing via pip and conda (https://camelot-py.readthedocs.io/en/master/user/install-deps.html), but not Poetry. As I understand (or misunderstand) it, packages are added to Poetry environments via the pyproject.toml file and then calling "poetry install."

I updated pyrpoject.toml as follows, having identified the current Camelot version as 0.10.1 (camelot --version):

[tool.poetry.dependencies]
python = "^3.8"
PyPDF2 = "2.12.1"
camelot = "^0.9.0"

This led to the error:

Because camelot3 depends on camelot (^0.9.0) which doesn't match any versions, version solving failed.

Same problem if I set (camelot = "0.10.1"). So I took the Camelot reference out of pyproject.toml, and ran the following command from within my Poetry virtual environment:

pip install “camelot-py[base]”

I was able to successfully proceed from here, but that doesn’t feel right. Is it wrong to try to force this project into Poetry, and should I instead consider using different package managers for different projects? Am I misunderstanding how Poetry works? What else am I missing here?

sinoroc
  • 18,409
  • 2
  • 39
  • 70
robcat26
  • 3
  • 1
  • What about `poetry add 'camelot-py[base]'`? – sinoroc Jan 30 '23 at 18:54
  • Thanks @sinoroc, that did it! Could I generalize, anywhere I see pip install instructions (which in this case let me know to add [base], which is not needed in Conda) I can use Poetry "add" with essentially the same parameter? – robcat26 Jan 30 '23 at 20:27
  • Yes, whenever you see `pip install 'Something[extra]'` you can replace it with `poetry add 'Something[extra]'`. You can also add it directly in the `pyproject.toml` then run `poetry install` instead. -- Note that in your question you wrote `camelot` in the `pyproject.toml` but it is `camelot-py` that you should have written. – sinoroc Jan 30 '23 at 22:16

1 Answers1

0

Whenever you see pip install 'Something[extra]' you can replace it with poetry add 'Something[extra]'.

Alternatively you can write it directly in the pyproject.toml and then run poetry install instead:

[tool.poetry.dependencies]
# ...
Something = { extras = ["extra"] }

Note that in your question you wrote camelot in the pyproject.toml but it is camelot-py that you should have written.

sinoroc
  • 18,409
  • 2
  • 39
  • 70
  • Thanks! That makes sense- looking at my pyproject.toml file after "poetry add...," I now see:
    camelot-py = {extras = ["base"], version = "^0.10.1"}
    – robcat26 Jan 31 '23 at 01:06