bax*_*axx 37 python numpy python-poetry
我不确定这篇文章到底需要提供哪些信息/上下文才能得到正确的回答 - 因此,如果我可以添加更多信息,请告诉我。
\n在尝试安装软件包时,我收到一条错误消息,如下所示:
\n Invalid hashes (sha256:01d6b62184e55367ce7d770bd87d97a6cfaf783ff7ba8328e7473a339fe19807) for numpy (1.22.2)\nRun Code Online (Sandbox Code Playgroud)\n我不知道如何解决这个问题。
\npoetry --version(install-check-clU745_7-py3.8) \xe2\x9e\x9c install_check poetry --version\nPoetry version 1.1.12\nRun Code Online (Sandbox Code Playgroud)\npoetry env info输出poetry env info:
(install-check-clU745_7-py3.8) \xe2\x9e\x9c install_check poetry env info\n\nVirtualenv\nPython: 3.8.12\nImplementation: CPython\nPath: /Users/user_name/Library/Caches/pypoetry/virtualenvs/install-check-clU745_7-py3.8\nValid: True\n\nSystem\nPlatform: darwin\nOS: posix\nPython: /Users/user_name/.pyenv/versions/3.8.12\nRun Code Online (Sandbox Code Playgroud)\npyproject.toml配置:
(install-check-clU745_7-py3.8) \xe2\x9e\x9c install_check cat pyproject.toml\n[tool.poetry]\nname = "install_check"\nversion = "0.1.0"\ndescription = ""\nauthors = ["user_name <user_name@email_add.com>"]\n\n[tool.poetry.dependencies]\npython = "^3.8"\n\n[tool.poetry.dev-dependencies]\npytest = "^5.2"\n\n[build-system]\nrequires = ["poetry-core>=1.0.0"]\nbuild-backend = "poetry.core.masonry.api"\nRun Code Online (Sandbox Code Playgroud)\n以下是清晰地概述此问题的再现的尝试:
\n Invalid hashes (sha256:01d6b62184e55367ce7d770bd87d97a6cfaf783ff7ba8328e7473a339fe19807) for numpy (1.22.2)\nRun Code Online (Sandbox Code Playgroud)\n接下来,在离开并重新访问目录以激活环境后,我有:
\n(install-check-clU745_7-py3.8) \xe2\x9e\x9c install_check which python\n/Users/user_name/Library/Caches/pypoetry/virtualenvs/install-check-clU745_7-py3.8/bin/python\n(install-check-clU745_7-py3.8) \xe2\x9e\x9c install_check python --version\nPython 3.8.12\nRun Code Online (Sandbox Code Playgroud)\n尝试添加 pandas 然后出现以下错误:
\n(install-check-clU745_7-py3.8) \xe2\x9e\x9c install_check poetry add pandas\nUsing version ^1.4.0 for pandas\n\nUpdating dependencies\nResolving dependencies... (2.3s)\n\nWriting lock file\n\nPackage operations: 5 installs, 0 updates, 0 removals\n\n \xe2\x80\xa2 Installing six (1.16.0)\n \xe2\x80\xa2 Installing numpy (1.22.2): Failed\n\n RuntimeError\n\n Invalid hashes (sha256:01d6b62184e55367ce7d770bd87d97a6cfaf783ff7ba8328e7473a339fe19807) for numpy (1.22.2) using archive numpy-1.22.2-cp38-cp38-macosx_10_14_x86_64.whl. Expected one of sha256:03ae5850619abb34a879d5f2d4bb4dcd025d6d8fb72f5e461dae84edccfe129f, sha256:076aee5a3763d41da6bef9565fdf3cb987606f567cd8b104aded2b38b7b47abf, sha256:0b536b6840e84c1c6a410f3a5aa727821e6108f3454d81a5cd5900999ef04f89, sha256:15efb7b93806d438e3bc590ca8ef2f953b0ce4f86f337ef4559d31ec6cf9d7dd, sha256:168259b1b184aa83a514f307352c25c56af111c269ffc109d9704e81f72e764b, sha256:2638389562bda1635b564490d76713695ff497242a83d9b684d27bb4a6cc9d7a, sha256:3556c5550de40027d3121ebbb170f61bbe19eb639c7ad0c7b482cd9b560cd23b, sha256:4a176959b6e7e00b5a0d6f549a479f869829bfd8150282c590deee6d099bbb6e, sha256:515a8b6edbb904594685da6e176ac9fbea8f73a5ebae947281de6613e27f1956, sha256:55535c7c2f61e2b2fc817c5cbe1af7cb907c7f011e46ae0a52caa4be1f19afe2, sha256:59153979d60f5bfe9e4c00e401e24dfe0469ef8da6d68247439d3278f30a180f, sha256:60cb8e5933193a3cc2912ee29ca331e9c15b2da034f76159b7abc520b3d1233a, sha256:6767ad399e9327bfdbaa40871be4254d1995f4a3ca3806127f10cec778bd9896, sha256:76a4f9bce0278becc2da7da3b8ef854bed41a991f4226911a24a9711baad672c, sha256:8cf33634b60c9cef346663a222d9841d3bbbc0a2f00221d6bcfd0d993d5543f6, sha256:94dd11d9f13ea1be17bac39c1942f527cbf7065f94953cf62dfe805653da2f8f, sha256:aafa46b5a39a27aca566198d3312fb3bde95ce9677085efd02c86f7ef6be4ec7, sha256:badca914580eb46385e7f7e4e426fea6de0a37b9e06bec252e481ae7ec287082, sha256:d76a26c5118c4d96e264acc9e3242d72e1a2b92e739807b3b69d8d47684b6677.\n\n at ~/Library/Application Support/pypoetry/venv/lib/python3.7/site-packages/poetry/installation/executor.py:632 in _download_link\n 628\xe2\x94\x82 "Invalid hashes ({}) for {} using archive {}. Expected one of {}.".format(\n 629\xe2\x94\x82 ", ".join(sorted(archive_hashes)),\n 630\xe2\x94\x82 package,\n 631\xe2\x94\x82 archive_path.name,\n \xe2\x86\x92 632\xe2\x94\x82 ", ".join(sorted(hashes)),\n 633\xe2\x94\x82 )\n 634\xe2\x94\x82 )\n 635\xe2\x94\x82\n 636\xe2\x94\x82 return archive\n\n \xe2\x80\xa2 Installing python-dateutil (2.8.2)\n \xe2\x80\xa2 Installing pytz (2021.3)\n\nFailed to add packages, reverting the pyproject.toml file to its original content.\nRun Code Online (Sandbox Code Playgroud)\ncurl -sSL https://install.python-poetry.org | python3 - --uninstall\nRun Code Online (Sandbox Code Playgroud)\n尝试遵循我安装的这个问题评论:
\ncurl -sSL https://install.python-poetry.org | python3 - --version 1.1.8\nRun Code Online (Sandbox Code Playgroud)\n我仍然遇到失败。
\npython --version\n Python 3.8.12\n\npoetry --version\n Poetry version 1.1.8\n\npoetry new install_check_2\n Created package install_check_2 in install_check_2\n\ncd install_check_2\nRun Code Online (Sandbox Code Playgroud)\n然后在新创建的项目中:
\npoetry env use python3.8\n Creating virtualenv install-check-2-1m3rSWN1-py3.8 in /Users/user_name/Library/Caches/pypoetry/virtualenvs\n Using virtualenv: /Users/user_name/Library/Caches/pypoetry/virtualenvs/install-check-2-1m3rSWN1-py3.8\n\npoetry install\n Updating dependencies\n Resolving dependencies... (4.9s)\n\n Writing lock file\n\n Package operations: 8 installs, 0 updates, 0 removals\n\n \xe2\x80\xa2 Installing pyparsing (3.0.7): Failed\n\n AttributeError\n\n \'Link\' object has no attribute \'is_absolute\'\n\n at ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/core/packages/file_dependency.py:33 in __init__\n 29\xe2\x94\x82 self._path = path\n 30\xe2\x94\x82 self._base = base or Path.cwd()\n 31\xe2\x94\x82 self._full_path = path\n 32\xe2\x94\x82\n \xe2\x86\x92 33\xe2\x94\x82 if not self._path.is_absolute():\n 34\xe2\x94\x82 try:\n 35\xe2\x94\x82 self._full_path = self._base.joinpath(self._path).resolve()\n 36\xe2\x94\x82 except FileNotFoundError:\n 37\xe2\x94\x82 raise ValueError("Directory {} does not exist".format(self._path))\nRun Code Online (Sandbox Code Playgroud)\n
Tho*_*mas 55
有几个 问题 报告。一个常见的原因是同时运行多个 Poetry 实例;另一个是中止下载(例如^C)。应该修复诗歌,以减少在这种情况下发生损坏的可能性,并且也许可以尝试自动再次下载损坏的文件。
在此之前,解决方法是从缓存中删除有问题的文件,并让 Poetry 下载新的副本。
您可以像这样找到有问题的文件的完整路径:
$ find ~/.cache/pypoetry -name numpy-1.22.2-cp38-cp38-macosx_10_14_x86_64.whl
Run Code Online (Sandbox Code Playgroud)
或者,对于懒人来说,只需清除整个缓存即可:
$ rm -rf ~/.cache/pypoetry
Run Code Online (Sandbox Code Playgroud)
pho*_*nix 44
我ctrl-C在 a 期间poetry install,导致其中一个缓存的轮子部分下载,并且哈希值与 PyPI 上的内容不匹配。
在装有 Poetry 1.1.13 的 macOS 上,唯一对我有用的方法是Yihua Zhou 的评论:
rm -r ~/Library/Caches/pypoetry/cache
rm -r ~/Library/Caches/pypoetry/artifacts
Run Code Online (Sandbox Code Playgroud)
Hob*_*rks 21
也许这是一个解决方案:
poetry cache clear . --all
rm poetry.lock
poetry install
Run Code Online (Sandbox Code Playgroud)
https://github.com/python-poetry/poetry/issues/4523#issuecomment-923155835
如果您在 Docker 映像中执行此操作,除了上面的答案之外,我还必须执行以下操作:
docker builder prune
Run Code Online (Sandbox Code Playgroud)
如果在 Dockerfile 中使用一些最新的 docker 构建缓存功能,这可能是必要的,例如:
RUN --mount=type=cache,target=$POETRY_CACHE_DIR/cache \
--mount=type=cache,target=$POETRY_CACHE_DIR/artifacts \
poetry install
Run Code Online (Sandbox Code Playgroud)
这是因为诗歌缓存位于主机文件系统上,需要清除,原因与上述答案相同。