Search code examples
python-venvpython-poetry

Poetry: "The dependency name for <package_name> does not match the actual package's name: <different_package_name>


I refactored the names of several of my packages, which are dependencies that are imported into my user program. This triggered changes to the repo names on Github, project names in Pycharm, import statements used within the projects, names of virtual environments used by Poetry, and the Poetry .toml files. The dependencies are under active development, so Poetry installs the latest commit for each dependencies. Despite scrubbing all files for consistency, I received the following error when running poetry update:

"The dependency name for <package_name> does not match the actual package's name: <different_package_name>


Solution

  • The problem was due to Poetry pulling old versions of the dependencies because the changes had not been committed and pushed.

    I followed the steps below, which may be helpful to you for troubleshooting Poetry.

    1. I used poetry config --list to review my Poetry configuration. This provided paths to my cache and virtual environments. Others suggested that removing the contents of these folders may clear out issues from linking to stale data.
    cache-dir = "/path/to/.cache/pypoetry"
    virtualenvs.path = "/path/to/.venv"
    
    1. I also ran the failing command in verbose mode (i.e., poetry update -vvv), which provided a stack trace of the error and also allowed me to see what and where my dependencies were pulled: Cloning <dependency.git> at 'HEAD' to /path/to/.venv/<dependency>. Text searching (grepping) this location enabled me to locate the offending package name text.