导入 PyYAML、cltk 时出现问题

mik*_*abs 7 macos pip setuptools pyyaml pyenv

我刚拿到一台MacBook,克隆了我正在做的项目,然后去设置python环境。创建环境后,我更新了 pip 并尝试使用pip install -r requirements.txt. 给我带来问题的 3 个库是cltkPyYAMLstanza

\n

这是执行后给我的pip install -r requirements.txt

\n
Collecting PyYAML==5.4.1 (from -r requirements.txt (line 56))\n  Using cached PyYAML-5.4.1.tar.gz (175 kB)\n  Installing build dependencies ... done\n  Getting requirements to build wheel ... error\n  error: subprocess-exited-with-error\n  \n  \xc3\x97 Getting requirements to build wheel did not run successfully.\n  \xe2\x94\x82 exit code: 1\n  \xe2\x95\xb0\xe2\x94\x80> [62 lines of output]\n      running egg_info\n      writing lib3/PyYAML.egg-info/PKG-INFO\n      writing dependency_links to lib3/PyYAML.egg-info/dependency_links.txt\n      writing top-level names to lib3/PyYAML.egg-info/top_level.txt\n      /private/var/folders/lk/14gmp9zs33512s20nwz_329c0000gn/T/pip-build-env-pbxz96he/overlay/lib/python3.8/site-packages/setuptools/config/setupcfg.py:293: _DeprecatedConfig: Deprecated config in `setup.cfg`\n      !!\n      \n              ********************************************************************************\n              The license_file parameter is deprecated, use license_files instead.\n      \n              By 2023-Oct-30, you need to update your project and remove deprecated calls\n              or your builds will no longer be supported.\n      \n              See https://setuptools.pypa.io/en/latest/userguide/declarative_config.html for details.\n              ********************************************************************************\n      \n      !!\n        parsed = self.parsers.get(option_name, lambda x: x)(value)\n      Traceback (most recent call last):\n        File "/Users/mikerabayda/repos/github.com/public/FastBridge/env/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>\n          main()\n        File "/Users/mikerabayda/repos/github.com/public/FastBridge/env/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main\n          json_out['return_val'] = hook(**hook_input['kwargs'])\n        File "/Users/mikerabayda/repos/github.com/public/FastBridge/env/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel\n          return hook(config_settings)\n        File "/private/var/folders/lk/14gmp9zs33512s20nwz_329c0000gn/T/pip-build-env-pbxz96he/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 341, in get_requires_for_build_wheel\n          return self._get_build_requires(config_settings, requirements=['wheel'])\n        File "/private/var/folders/lk/14gmp9zs33512s20nwz_329c0000gn/T/pip-build-env-pbxz96he/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 323, in _get_build_requires\n          self.run_setup()\n        File "/private/var/folders/lk/14gmp9zs33512s20nwz_329c0000gn/T/pip-build-env-pbxz96he/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 338, in run_setup\n          exec(code, locals())\n        File "<string>", line 271, in <module>\n        File "/private/var/folders/lk/14gmp9zs33512s20nwz_329c0000gn/T/pip-build-env-pbxz96he/overlay/lib/python3.8/site-packages/setuptools/__init__.py", line 107, in setup\n          return distutils.core.setup(**attrs)\n        File "/private/var/folders/lk/14gmp9zs33512s20nwz_329c0000gn/T/pip-build-env-pbxz96he/overlay/lib/python3.8/site-packages/setuptools/_distutils/core.py", line 185, in setup\n          return run_commands(dist)\n        File "/private/var/folders/lk/14gmp9zs33512s20nwz_329c0000gn/T/pip-build-env-pbxz96he/overlay/lib/python3.8/site-packages/setuptools/_distutils/core.py", line 201, in run_commands\n          dist.run_commands()\n        File "/private/var/folders/lk/14gmp9zs33512s20nwz_329c0000gn/T/pip-build-env-pbxz96he/overlay/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands\n          self.run_command(cmd)\n        File "/private/var/folders/lk/14gmp9zs33512s20nwz_329c0000gn/T/pip-build-env-pbxz96he/overlay/lib/python3.8/site-packages/setuptools/dist.py", line 1234, in run_command\n          super().run_command(command)\n        File "/private/var/folders/lk/14gmp9zs33512s20nwz_329c0000gn/T/pip-build-env-pbxz96he/overlay/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 988, in run_command\n          cmd_obj.run()\n        File "/private/var/folders/lk/14gmp9zs33512s20nwz_329c0000gn/T/pip-build-env-pbxz96he/overlay/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 314, in run\n          self.find_sources()\n        File "/private/var/folders/lk/14gmp9zs33512s20nwz_329c0000gn/T/pip-build-env-pbxz96he/overlay/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 322, in find_sources\n          mm.run()\n        File "/private/var/folders/lk/14gmp9zs33512s20nwz_329c0000gn/T/pip-build-env-pbxz96he/overlay/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 551, in run\n          self.add_defaults()\n        File "/private/var/folders/lk/14gmp9zs33512s20nwz_329c0000gn/T/pip-build-env-pbxz96he/overlay/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 589, in add_defaults\n          sdist.add_defaults(self)\n        File "/private/var/folders/lk/14gmp9zs33512s20nwz_329c0000gn/T/pip-build-env-pbxz96he/overlay/lib/python3.8/site-packages/setuptools/command/sdist.py", line 104, in add_defaults\n          super().add_defaults()\n        File "/private/var/folders/lk/14gmp9zs33512s20nwz_329c0000gn/T/pip-build-env-pbxz96he/overlay/lib/python3.8/site-packages/setuptools/_distutils/command/sdist.py", line 251, in add_defaults\n          self._add_defaults_ext()\n        File "/private/var/folders/lk/14gmp9zs33512s20nwz_329c0000gn/T/pip-build-env-pbxz96he/overlay/lib/python3.8/site-packages/setuptools/_distutils/command/sdist.py", line 336, in _add_defaults_ext\n          self.filelist.extend(build_ext.get_source_files())\n        File "<string>", line 201, in get_source_files\n        File "/private/var/folders/lk/14gmp9zs33512s20nwz_329c0000gn/T/pip-build-env-pbxz96he/overlay/lib/python3.8/site-packages/setuptools/_distutils/cmd.py", line 107, in __getattr__\n          raise AttributeError(attr)\n      AttributeError: cython_sources\n      [end of output]\n  \n  note: This error originates from a subprocess, and is likely not a problem with pip.\nerror: subprocess-exited-with-error\n\n\xc3\x97 Getting requirements to build wheel did not run successfully.\n\xe2\x94\x82 exit code: 1\n\xe2\x95\xb0\xe2\x94\x80> See above for output.\n\nnote: This error originates from a subprocess, and is likely not a problem with pip.\n
Run Code Online (Sandbox Code Playgroud)\n

我注意到requirements.txt它指定了所有软件包的版本,我尝试将它们取出来让 pip 解决依赖性问题并得到相同的错误。我尝试在下载其他文件后手动删除cltkPyYAML和pip 安装它们,但遇到类似的依赖性问题。stanzarequirements.txt

\n

这仍然在我的另一台计算机上使用 python 的虚拟环境中的 WSL 上运行3.8.10,但我无法让它在这个新计算机上运行。我正在使用3.8.17并尝试过更新的 python 版本,但成功率为 0。

\n

小智 5

5.4.1这是您尝试安装的版本PyYAML 中的一个错误。它于上周开放,建议的解决方法是使用以前的次要版本5.3.1

更多信息请参见: https://github.com/yaml/pyyaml/issues/724

所以,在你的requirements.txt

...
PyYAML==5.3.1
Run Code Online (Sandbox Code Playgroud)


小智 2

Snyk 显示PyYAML==5.3.1 存在严重安全问题。通过升级到版本 6.0.1 进行修复。