python - Python3.7 pip install requirements_string 解析错误
问题描述
我对python编码很陌生。我正在尝试在我的 python 脚本中使用现有的自定义包。
所以我想将一个 python 包与我的一个 python 脚本一起使用。要使用现有的包(或*.egg
)文件,我遵循以下命令:
- 通过执行以下命令,从我的 lib 的根目录构建一个 python egg 发行版:
python3 setup.py bdist_egg
- 在我的 python 脚本目录中尝试执行以下命令来安装
.egg
在上面的步骤中创建的:python3.7 -m pip install <path>/<to>/dist/<my_custom_lib>-0.14.0-py3.7.egg
这给了我以下错误:
ERROR: Exception:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip/_vendor/packaging/requirements.py", line 98, in __init__
req = REQUIREMENT.parseString(requirement_string)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip/_vendor/pyparsing.py", line 1955, in parseString
raise exc
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip/_vendor/pyparsing.py", line 3814, in parseImpl
raise ParseException(instring, loc, self.errmsg, self)
pip._vendor.pyparsing.ParseException: Expected stringEnd, found '/' (at char 15), (line:1, col:16)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip/_internal/req/constructors.py", line 358, in parse_req_from_line
req = Requirement(req_as_string)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip/_vendor/packaging/requirements.py", line 102, in __init__
requirement_string[e.loc : e.loc + 8], e.msg
pip._vendor.packaging.requirements.InvalidRequirement: Parse error at "'/dist/me'": Expected stringEnd
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip/_internal/cli/base_command.py", line 188, in _main
status = self.run(options, args)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip/_internal/cli/req_command.py", line 185, in wrapper
return func(self, options, args)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip/_internal/commands/install.py", line 302, in run
check_supported_wheels=not options.target_dir,
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip/_internal/cli/req_command.py", line 323, in get_requirements
use_pep517=options.use_pep517,
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip/_internal/req/constructors.py", line 396, in install_req_from_line
parts = parse_req_from_line(name, line_source)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip/_internal/req/constructors.py", line 362, in parse_req_from_line
add_msg += deduce_helpful_msg(req_as_string)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip/_internal/req/constructors.py", line 169, in deduce_helpful_msg
next(parse_requirements(fp.read()))
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/codecs.py", line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xcb in position 12: invalid continuation byte
无法弄清楚为什么会发生这种情况。如果这是由于setup.py
主库中的文件内容,这是它的内容:
from setuptools import setup, find_packages
setup(
name='my_custom_lib',
version='0.14.0',
packages=find_packages(),
url='https://www.my_custom_lib.com/qa/my_custom_lib',
license='my_custom_lib Networks',
author='my_custom_lib',
author_email='my_custom_lib@my_custom_lib.com',
description='Simulator library for the my_custom_lib Platform',
long_description='''
This Python module provides functionality to simulate an STB client
using various protocol implementations, to test the
my_custom_lib platform''',
classifiers=[
'Development Status :: 3 - Alpha',
'Environment :: Console',
'Intended Audience :: Telecom',
'Programming Language :: Python',
],
install_requires=[
'protocols',
'numpy',
'requests',
'pycrypto',
'psutil'
],
)
不知道是什么导致了这个问题,或者我在这里做错了什么。感谢您对此的所有投入和评论。
解决方案
推荐阅读
- javascript - 获取 Cesium3DTileset 中特征的几何图形
- python - 在 jupyter 笔记本/终端中执行 cdo(气候数据操作员)包中的命令时出现问题
- swift - 如何水平对齐状态栏项目文本?
- windows - 在 Windows Sever 2016 上使用本机 tar PowerShell cmdlet
- sql - 在 R 中到达分布在多个 Postgres 服务器中的分片数据
- system.reactive - 如何绑定 ObservableCollection
可变模型到 ReadOnlyObservableCollection 使用 ReactiveUI 和 DynamicData 的视图模型 - reporting-services - 将 VS 2017 SSDT 使用的 DLL 放在哪里
- atom-editor - Atom:如何使用片段制作换行符
- java - SQS 可以触发 AWS 事件桥服务中的事件吗?
- javascript - 如何使用谷歌应用脚本在谷歌电子表格中添加唯一条目