poetry icon indicating copy to clipboard operation
poetry copied to clipboard

currupted version of pip/setuptools/virtualenv in cache

Open robtovey opened this issue 1 year ago • 0 comments

Description

TLDR: if you're having problems with corrupt pip/setuptools, then delete ~/. local/share/virtualenv

I tried to install a new environment today and ran into a lot of weird import errors from pip. I quite soon realised that the cached version of pip was corrupted and it couldn't even import to run a poetry install/update command. Reading #732 taught me that poetry uses virtualenv to initialise environments with pip and setuptools before performing any further operations.

I'm posting this issue for documentation reasons rather than in order to fix the original error. I searched quite hard on the issues and the documentation but didn't find any reference to this cache (in the end I ran poetry -vvv install which printed where it was retrieving virtualenv from).

It would be really useful if there could be some documentation of where the various caches are stored for poetry, they are often the source of "sudden weird bugs". The three caches I can find documented here are config, data, and cache. Only the cache is listed by poetry config --list, and only the data directory is mentioned in the uninstall guide. It would be nice if the source of virtualenv could also be listed there, I'm sure it's a common debugging route. I also find it a bit inconsistent to suggest only deleting the "data" folder and not the other ones in the uninstall guide, but not essential.

Thanks for your help.

Workarounds

Just delete all caches :)

Poetry Installation Method

other

Operating System

(WSL) Ubuntu 22.04.03

Poetry Version

1.8.3

Poetry Configuration

cache-dir = "/home/robtovey/.cache/pypoetry"
experimental.system-git-client = false
installer.max-workers = null
installer.modern-installation = true
installer.no-binary = null
installer.parallel = true
keyring.enabled = true
solver.lazy-wheel = true
virtualenvs.create = true
virtualenvs.in-project = true
virtualenvs.options.always-copy = false
virtualenvs.options.no-pip = false
virtualenvs.options.no-setuptools = false
virtualenvs.options.system-site-packages = false
virtualenvs.path = "{cache-dir}/virtualenvs"  # /home/robtovey/.cache/pypoetry/virtualenvs
virtualenvs.prefer-active-python = false
virtualenvs.prompt = "{project_name}-py{python_version}"
warnings.export = true

Python Sysconfig

No response

Example pyproject.toml

No response

Poetry Runtime Logs

poetry -vvv install

Loading configuration file /home/robtovey/.config/pypoetry/config.toml
Using virtualenv: /home/robtovey/motor_optimization/projects/budapest/.venv
Installing dependencies from lock file

Finding the necessary packages for the current system
[virtualenv] find interpreter for spec PythonSpec(path=/home/robtovey/.local/share/pypoetry/venv/bin/python)
[virtualenv] filesystem is case-sensitive
[filelock:filelock] Attempting to acquire lock 139851713090832 on /home/robtovey/.local/share/virtualenv/py_info/1/49bf313f9137c9b5e7d96b7416a2e7257f93b7815166ea852dd8b16329afe13b.lock
[filelock:filelock] Lock 139851713090832 acquired on /home/robtovey/.local/share/virtualenv/py_info/1/49bf313f9137c9b5e7d96b7416a2e7257f93b7815166ea852dd8b16329afe13b.lock
[virtualenv] got python info of %s from (PosixPath('/home/robtovey/.pyenv/versions/3.11.8/bin/python'), PosixPath('/home/robtovey/.local/share/virtualenv/py_info/1/49bf313f9137c9b5e7d96b7416a2e7257f93b7815166ea852dd8b16329afe13b.json'))
[filelock:filelock] Attempting to release lock 139851713090832 on /home/robtovey/.local/share/virtualenv/py_info/1/49bf313f9137c9b5e7d96b7416a2e7257f93b7815166ea852dd8b16329afe13b.lock
[filelock:filelock] Lock 139851713090832 released on /home/robtovey/.local/share/virtualenv/py_info/1/49bf313f9137c9b5e7d96b7416a2e7257f93b7815166ea852dd8b16329afe13b.lock
[virtualenv] proposed PythonInfo(spec=CPython3.11.8.final.0-64, system=/home/robtovey/.pyenv/versions/3.11.8/bin/python, exe=/home/robtovey/.local/share/pypoetry/venv/bin/python, platform=linux, version='3.11.8 (main, Feb 29 2024, 14:42:39) [GCC 11.4.0]', encoding_fs_io=utf-8-utf-8)
[virtualenv] accepted PythonInfo(spec=CPython3.11.8.final.0-64, system=/home/robtovey/.pyenv/versions/3.11.8/bin/python, exe=/home/robtovey/.local/share/pypoetry/venv/bin/python, platform=linux, version='3.11.8 (main, Feb 29 2024, 14:42:39) [GCC 11.4.0]', encoding_fs_io=utf-8-utf-8)
[virtualenv] create virtual environment via CPython3Posix(dest=/tmp/tmp_eaq1e75/.venv, clear=False, no_vcs_ignore=False, global=False)
[virtualenv] create folder /tmp/tmp_eaq1e75/.venv/bin
[virtualenv] create folder /tmp/tmp_eaq1e75/.venv/lib/python3.11/site-packages
[virtualenv] write /tmp/tmp_eaq1e75/.venv/pyvenv.cfg
[virtualenv]    home = /home/robtovey/.pyenv/versions/3.11.8/bin
[virtualenv]    implementation = CPython
[virtualenv]    version_info = 3.11.8.final.0
[virtualenv]    virtualenv = 20.26.3
[virtualenv]    include-system-site-packages = false
[virtualenv]    base-prefix = /home/robtovey/.pyenv/versions/3.11.8
[virtualenv]    base-exec-prefix = /home/robtovey/.pyenv/versions/3.11.8
[virtualenv]    base-executable = /home/robtovey/.pyenv/versions/3.11.8/bin/python3.11
[virtualenv] symlink /home/robtovey/.pyenv/versions/3.11.8/bin/python to /tmp/tmp_eaq1e75/.venv/bin/python
[virtualenv] create virtualenv import hook file /tmp/tmp_eaq1e75/.venv/lib/python3.11/site-packages/_virtualenv.pth
[virtualenv] create /tmp/tmp_eaq1e75/.venv/lib/python3.11/site-packages/_virtualenv.py
[virtualenv] ============================== target debug ==============================
[virtualenv] debug via /tmp/tmp_eaq1e75/.venv/bin/python /home/robtovey/.local/share/pypoetry/venv/lib/python3.11/site-packages/virtualenv/create/debug.py
[virtualenv] {
[virtualenv]   "sys": {
[virtualenv]     "executable": "/tmp/tmp_eaq1e75/.venv/bin/python",
[virtualenv]     "_base_executable": "/home/robtovey/.pyenv/versions/3.11.8/bin/python3.11",
[virtualenv]     "prefix": "/tmp/tmp_eaq1e75/.venv",
[virtualenv]     "base_prefix": "/home/robtovey/.pyenv/versions/3.11.8",
[virtualenv]     "real_prefix": null,
[virtualenv]     "exec_prefix": "/tmp/tmp_eaq1e75/.venv",
[virtualenv]     "base_exec_prefix": "/home/robtovey/.pyenv/versions/3.11.8",
[virtualenv]     "path": [
[virtualenv]       "/home/robtovey/.pyenv/versions/3.11.8/lib/python311.zip",
[virtualenv]       "/home/robtovey/.pyenv/versions/3.11.8/lib/python3.11",
[virtualenv]       "/home/robtovey/.pyenv/versions/3.11.8/lib/python3.11/lib-dynload",
[virtualenv]       "/tmp/tmp_eaq1e75/.venv/lib/python3.11/site-packages"
[virtualenv]     ],
[virtualenv]     "meta_path": [
[virtualenv]       "<class '_virtualenv._Finder'>",
[virtualenv]       "<class '_frozen_importlib.BuiltinImporter'>",
[virtualenv]       "<class '_frozen_importlib.FrozenImporter'>",
[virtualenv]       "<class '_frozen_importlib_external.PathFinder'>"
[virtualenv]     ],
[virtualenv]     "fs_encoding": "utf-8",
[virtualenv]     "io_encoding": "utf-8"
[virtualenv]   },
[virtualenv]   "version": "3.11.8 (main, Feb 29 2024, 14:42:39) [GCC 11.4.0]",
[virtualenv]   "makefile_filename": "/home/robtovey/.pyenv/versions/3.11.8/lib/python3.11/config-3.11-x86_64-linux-gnu/Makefile",
[virtualenv]   "os": "<module 'os' (frozen)>",
[virtualenv]   "site": "<module 'site' (frozen)>",
[virtualenv]   "datetime": "<module 'datetime' from '/home/robtovey/.pyenv/versions/3.11.8/lib/python3.11/datetime.py'>",
[virtualenv]   "math": "<module 'math' from '/home/robtovey/.pyenv/versions/3.11.8/lib/python3.11/lib-dynload/math.cpython-311-x86_64-linux-gnu.so'>",
[virtualenv]   "json": "<module 'json' from '/home/robtovey/.pyenv/versions/3.11.8/lib/python3.11/json/__init__.py'>"
[virtualenv] }
[virtualenv] add seed packages via FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/robtovey/.local/share/virtualenv)

where the last line indicates the virtualenv cache location

robtovey avatar Aug 20 '24 13:08 robtovey