使用setup.py安装软件包时出现问题
我已经设置了setup.py,以从我从项目的虚拟环境中生成的requirements.txt中获取依赖项.如下:
I have setup.py set to get the dependencies from requirements.txt that I generate from my virtual environment of the project. As follows:
在我的视线中:
pip3 freeze > requirements.txt
然后:
with open('requirements.txt') as f:
required = f.read().splitlines()
setuptools.setup(
...
install_requires=required,
...
)
但是当我尝试安装我的软件包时,显示了此错误:
But I have this error displayed when I try to install my package:
raise RequirementParseError(str(e))
pip._vendor.pkg_resources.RequirementParseError: Parse error at "'(===file'": Expected stringEnd
因此,当检查我的requirements.txt文件时,我发现这一定是软件包安装失败的根本原因:
So when checking my requirements.txt file, I found this which must be the root cause of package installation failure:
avro-python3===file-.avro-VERSION.txt
我没有明确安装它,这是一个传递依赖.当我尝试安装avro-python3时,出现以下错误:
I didn't install it explicitly it is a transitive dependency. And when I try to install avro-python3 it, I get the following error:
Requirement already satisfied: avro-python3 in /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages (file-.avro-VERSION.txt)
该如何解决我的问题?
谢谢.
发生此错误是因为 setup
方法不希望版本具有 file-.avro-VERSION格式.txt
.我怀疑字符-"是否包含是解析器困扰的原因,因为它希望字符串以结尾而不是该字符结尾.
This error happens because the setup
method is not expecting a version to have the format file-.avro-VERSION.txt
. I suspect that the character "-" is what bothers the parser, as it expects the string to end instead of that character.
我建议您尝试在 requirements.txt
文件,问题应该消失了.
I suggest you try to use one of the official versions on the requirements.txt
file and the problem should be gone.