python - 诗歌已添加模块,但未安装
问题描述
我pyproject.toml
是这样的
[tool.poetry.dependencies]
python = "^3.8"
numpy = "^1.19.4"
pandas = "^1.1.5"
matplotlib = "^3.3.3"
seaborn = "^0.11.0"
lightgbm = "^3.1.1"
jupyter = "^1.0.0"
notebook = "^6.1.5"
.
.
.
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
打开python之后poetry install
,我发现我可以导入一些模块(numpy和pandas),但不能导入seaborn、lightgbm等其他模块。有人知道如何解决这个问题吗?我遇到了同样的情况,所以我手动删除了.venv
和poetry.lock
. 然后我重新添加了模块poetry install
。但是进展的并不顺利...
$ poetry run python
Python 3.9.1 (default, Dec 10 2020, 10:36:35)
[Clang 12.0.0 (clang-1200.0.32.27)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> import pandas
>>> import seaborn
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'seaborn'
>>> import lightgbm
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'lightgbm'
我想llvmlite
这是造成这个问题的主要原因,所以我会四处寻找解决方案。但是如果你已经知道了,请分享。
$ poetry cache clear pypi --all
$ rm -r .venv
$ rm poetry.lock
$ poetry install
### a lot of process goes on
• Installing colorama (0.4.4): Installing...
• Installing llvmlite (0.35.0rc3): Failed
• Installing llvmlite (0.35.0rc3): Failed
• Installing colorama (0.4.4)
• Installing llvmlite (0.35.0rc3): Failed
RuntimeError
Unable to find installation candidates for llvmlite (0.35.0rc3)
at /usr/local/Cellar/poetry/1.1.4/libexec/lib/python3.9/site-packages/poetry/installation/chooser.py:72 in choose_for
68│
69│ links.append(link)
70│
71│ if not links:
→ 72│ raise RuntimeError(
73│ "Unable to find installation candidates for {}".format(package)
74│ )
75│
76│ # Get the best link
以下是可能的解决线索
诗歌回复它已经安装。
$ poetry add seaborn
The following packages are already present in the pyproject.toml and will be skipped:
• seaborn
If you want to update it to the latest compatible version, you can use `poetry update package`.
If you prefer to upgrade it to the latest available version, you can use `poetry add package@latest`.
Nothing to add.
$ poetry run which python
/Users/<user>/.venv/bin/python
$ poetry env info
Virtualenv
Python: 3.9.1
Implementation: CPython
Path: /Users/<user>/.venv
Valid: True
System
Platform: darwin
OS: posix
Python: /usr/local/Cellar/python@3.9/3.9.1/Frameworks/Python.framework/Versions/3.9
$ poetry -V
Poetry version 1.1.4
解决方案
我解决了这个问题。这个问题只是安装失败llvmlite
,而不是诗歌。是安装我尝试安装llvmlite
的先决条件。pandas-profiling
寻找依赖问题的经验法则
- 删除当前环境
$ poetry cache list
# after finding out what cache exists
$ poetry cache clear <cache name> --all
$ rm -r .venv
$ rm poetry.lock
- 记下您已安装的模块的记录或副本
$ cat pyproject.toml
# take a note or copy of what modules you have installed
$ rm pyproject.toml
- 重新初始化环境并逐步添加模块
$ poetry init
# not adding modules except ones you are sure not to cause problem
$ poetry add <module>
- 确定真正的问题
推荐阅读
- r - R中的贴现累积和
- android - 启动前台服务时 Android 9 和 Android 10 的 RemoteServiceException
- python - 多列映射
- mysql - 使用 group_concat 在 INNER JOIN mysqli select 语句中变得具体
- ios - Nativescript 聊天 UI iOS 问题
- python - 暂停 Python 脚本并等待条件的有效方法?
- python - 如何在 Pandas 中获取具有键对值的列的计数
- java - 写清单
到 HDFS - ssl - 编译apk时Buildozer错误 - pip ssl
- css - 我可以在不知道图像宽度的情况下在 CSS 中裁剪图像的边缘吗?