python - pipenv 不安装 GitHub 包的依赖项
问题描述
我有一个 python 包上传到 GitHub。这个包使用 Pipenv 来管理依赖。另一方面,我有一个使用该库的 python 工具(并使用 Pipenv 来管理它自己的依赖项)。
查看我的包的 Pipfile,我们可以看到它有两个依赖项:
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
requests = "*"
loggly-python-handler = "*"
[dev-packages]
pylint = "*"
[requires]
python_version = "3.7"
在我的 python 工具中,我使用以下方法安装了我的包:
pipenv install -e git+https://github.com/<name>/<name>.git#egg=<name>
但是,在检查该工具的 pip 图时,看起来我的包没有依赖项:
(tool-aqleTTYE) C:\Projects\tool>pipenv graph
<my_package>==0.0.3
pylint==2.0.1
- astroid [required: >=2.0.1, installed: 2.0.1]
- lazy-object-proxy [required: Any, installed: 1.3.1]
- six [required: Any, installed: 1.11.0]
- wrapt [required: Any, installed: 1.10.11]
- colorama [required: Any, installed: 0.3.9]
- isort [required: >=4.2.5, installed: 4.3.4]
- mccabe [required: Any, installed: 0.6.1]
我希望看到我的包依赖于requests
and loggly-python-handler
。事实上,在运行代码时它说它找不到包依赖项..
pipenv run python tool.py
....
File "c:\.virtualenvs\tool-aqlettye\src\tool\tool\logger.py", line 35, in <module>
'level': 'DEBUG',
File "c:\python37\Lib\logging\config.py", line 792, in dictConfig
dictConfigClass(config).configure()
File "c:\python37\Lib\logging\config.py", line 563, in configure
'%r' % name) from e
ValueError: Unable to configure handler 'loggly'
只是为了确定:
(tool-aqleTTYE) C:\Projects\tool>python
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'requests'
这是一个错误还是我做错了什么?
解决方案
尝试:
pipenv lock --clear
这应该清除您的锁定文件。它对我有用。
只需卸载并安装后:
pipenv uninstall --all
然后
pipenv install
我第一次创建的自定义包(.whl)遇到了同样的问题,但没有在“setup.py”中定义依赖项(install_requires)。我将它上传到个人 pypi 存储库并安装它。在更正我的错误并使用要求更新它并重试安装它之后,依赖项不起作用。
我发现锁定文件没有显示依赖项更改,但“pipenv 图”显示了它们。
然后我在这里找到了命令
推荐阅读
- c# - C# 使用 2 个线程将数组值增加 1?
- django - AWS CodeStar/Pipeline 和 Python (Django/Flask) 的建议
- linux - 使用 F# 替代 Linux shell 脚本
- regex - 使用 PowerShell 从记事本中提取日期和时间戳
- cdi - 在 Quarkus 服务中找不到 SessionScoped bean
- oracle - 如何使用 SQL 开发人员将 Oracle 表查询数据放入多个 Excel 工作表?
- android - Android中的等效EKCalendarChooser
- python - 在 AWS Lambda 上使用 Python 中的 Pdf2img 将 pdf 页面转换为图像
- scala - 如何在 scala 隐式解析中使用 Any?
- android - 使用 ConstraintLayout 进行绝对定位