pippython-packagingpython-poetrypython-camelot

Trying to Avoid Using Two Package Managers (pip and Poetry) for the Same Project


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?


Solution

  • 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.