繁体   English   中英

从 github 和通过本地路径安装 python 模块时出错

[英]Error while installing python module from github and through local path

我正在尝试从 github 安装修改后的 python package。 当我尝试使用python3 setup.py install时,出现此错误

C:\Users\Maaz Shahid\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
C:\Users\Maaz Shahid\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\command\easy_install.py:144: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
running bdist_egg
running egg_info
writing obspy.egg-info\PKG-INFO
writing dependency_links to obspy.egg-info\dependency_links.txt
writing entry points to obspy.egg-info\entry_points.txt
writing namespace_packages to obspy.egg-info\namespace_packages.txt
writing requirements to obspy.egg-info\requires.txt
writing top-level names to obspy.egg-info\top_level.txt
reading manifest file 'obspy.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no previously-included files found matching 'appveyor.yml'
no previously-included directories found matching 'obspy\*\docs'
adding license file 'LICENSE.txt'
writing manifest file 'obspy.egg-info\SOURCES.txt'
installing library code to build\bdist.win-amd64\egg
running install_lib
running build_py
C:\Users\Maaz Shahid\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\command\build_py.py:202: SetuptoolsDeprecationWarning:     Installing 'obspy.clients.fdsn.tests.data' as data is deprecated, please list it in `packages`.
    !!


  ############################
    # Package would be ignored #
    ############################
    Python recognizes 'obspy.taup.tests.data.TauP_test_data' as an importable package,
    but it is not listed in the `packages` configuration of setuptools.

    'obspy.taup.tests.data.TauP_test_data' has been automatically added to the distribution only
    because it may contain data files, but this behavior is likely to change
    in future versions of setuptools (and therefore is considered deprecated).

    Please make sure that 'obspy.taup.tests.data.TauP_test_data' is included as a package by using
    the `packages` configuration field or the proper discovery methods
    (for example by using `find_namespace_packages(...)`/`find_namespace:`
    instead of `find_packages(...)`/`find:`).

    You can read more about "package discovery" and "data files" on setuptools
    documentation page.
...
...
...
  check.warn(importable)
running build_ext
building 'gse2' extension
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/

当我尝试使用pip install -e git+https://github.com/isas-yamamoto/obspy.git#egg=obspy

这是我得到的错误:

  error: subprocess-exited-with-error

  × Building editable for obspy (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [72 lines of output]
      C:\Users\Maaz Shahid\AppData\Local\Temp\pip-build-env-qvdwaw5u\overlay\Lib\site-packages\setuptools\_distutils\dist.py:262: UserWarning: Unknown distribution option: 'features'
        warnings.warn(msg)
      running editable_wheel
      creating C:\Users\Maaz Shahid\AppData\Local\Temp\pip-wheel-l704kmul\tmp4izgban0\obspy.egg-info
      writing C:\Users\Maaz Shahid\AppData\Local\Temp\pip-wheel-l704kmul\tmp4izgban0\obspy.egg-info\PKG-INFO
      writing dependency_links to C:\Users\Maaz Shahid\AppData\Local\Temp\pip-wheel-l704kmul\tmp4izgban0\obspy.egg-info\dependency_links.txt
      writing entry points to C:\Users\Maaz Shahid\AppData\Local\Temp\pip-wheel-l704kmul\tmp4izgban0\obspy.egg-info\entry_points.txt
      writing namespace_packages to C:\Users\Maaz Shahid\AppData\Local\Temp\pip-wheel-l704kmul\tmp4izgban0\obspy.egg-info\namespace_packages.txt
      writing requirements to C:\Users\Maaz Shahid\AppData\Local\Temp\pip-wheel-l704kmul\tmp4izgban0\obspy.egg-info\requires.txt
      writing top-level names to C:\Users\Maaz Shahid\AppData\Local\Temp\pip-wheel-l704kmul\tmp4izgban0\obspy.egg-info\top_level.txt
      writing manifest file 'C:\Users\Maaz Shahid\AppData\Local\Temp\pip-wheel-l704kmul\tmp4izgban0\obspy.egg-info\SOURCES.txt'
      reading manifest file 'C:\Users\Maaz Shahid\AppData\Local\Temp\pip-wheel-l704kmul\tmp4izgban0\obspy.egg-info\SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      warning: no previously-included files found matching 'appveyor.yml'
      no previously-included directories found matching 'obspy\*\docs'
      adding license file 'LICENSE.txt'
      writing manifest file 'C:\Users\Maaz Shahid\AppData\Local\Temp\pip-wheel-l704kmul\tmp4izgban0\obspy.egg-info\SOURCES.txt'
      creating 'C:\Users\Maaz Shahid\AppData\Local\Temp\pip-wheel-l704kmul\tmp4izgban0\obspy-1.3.0.post0+20.g5a3b135ba1.isas.yamamoto.feature.apollo.dist-info'
      adding license file "LICENSE.txt" (matched pattern "LICEN[CS]E*")
      C:\Users\Maaz Shahid\AppData\Local\Temp\pip-build-env-qvdwaw5u\normal\Lib\site-packages\wheel\bdist_wheel.py:80: RuntimeWarning: Config variable 'Py_DEBUG' is unset, Python ABI tag may be incorrect
        if get_flag('Py_DEBUG',
      creating C:\Users\Maaz Shahid\AppData\Local\Temp\pip-wheel-l704kmul\tmp4izgban0\obspy-1.3.0.post0+20.g5a3b135ba1.isas.yamamoto.feature.apollo.dist-info\WHEEL
      C:\Users\Maaz Shahid\AppData\Local\Temp\pip-build-env-qvdwaw5u\overlay\Lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build_py
      running build_ext
      building 'gse2' extension
      Traceback (most recent call last):
        File "C:\Users\Maaz Shahid\AppData\Local\Temp\pip-build-env-qvdwaw5u\overlay\Lib\site-packages\setuptools\command\editable_wheel.py", line 140, in run
          self._create_wheel_file(bdist_wheel)
        File "C:\Users\Maaz Shahid\AppData\Local\Temp\pip-build-env-qvdwaw5u\overlay\Lib\site-packages\setuptools\command\editable_wheel.py", line 330, in _create_wheel_file
          files, mapping = self._run_build_commands(dist_name, unpacked, lib, tmp)
        File "C:\Users\Maaz Shahid\AppData\Local\Temp\pip-build-env-qvdwaw5u\overlay\Lib\site-packages\setuptools\command\editable_wheel.py", line 261, in _run_build_commands
          self._run_build_subcommands()
        File "C:\Users\Maaz Shahid\AppData\Local\Temp\pip-build-env-qvdwaw5u\overlay\Lib\site-packages\setuptools\command\editable_wheel.py", line 288, in _run_build_subcommands
          self.run_command(name)
        File "C:\Users\Maaz Shahid\AppData\Local\Temp\pip-build-env-qvdwaw5u\overlay\Lib\site-packages\setuptools\_distutils\cmd.py", line 319, in run_command
          self.distribution.run_command(command)
        File "C:\Users\Maaz Shahid\AppData\Local\Temp\pip-build-env-qvdwaw5u\overlay\Lib\site-packages\setuptools\dist.py", line 1217, in run_command
          super().run_command(command)
        File "C:\Users\Maaz Shahid\AppData\Local\Temp\pip-build-env-qvdwaw5u\overlay\Lib\site-packages\setuptools\_distutils\dist.py", line 992, in run_command
          cmd_obj.run()
        File "C:\Users\Maaz Shahid\AppData\Local\Temp\pip-build-env-qvdwaw5u\overlay\Lib\site-packages\setuptools\command\build_ext.py", line 84, in run
          _build_ext.run(self)
        File "C:\Users\Maaz Shahid\AppData\Local\Temp\pip-build-env-qvdwaw5u\overlay\Lib\site-packages\setuptools\_distutils\command\build_ext.py", line 346, in run
          self.build_extensions()
        File "C:\Users\Maaz Shahid\AppData\Local\Temp\pip-build-env-qvdwaw5u\overlay\Lib\site-packages\setuptools\_distutils\command\build_ext.py", line 466, in build_extensions
          self._build_extensions_serial()
        File "C:\Users\Maaz Shahid\AppData\Local\Temp\pip-build-env-qvdwaw5u\overlay\Lib\site-packages\setuptools\_distutils\command\build_ext.py", line 492, in _build_extensions_serial
          self.build_extension(ext)
        File "C:\Users\Maaz Shahid\AppData\Local\Temp\pip-build-env-qvdwaw5u\overlay\Lib\site-packages\setuptools\command\build_ext.py", line 246, in build_extension
          _build_ext.build_extension(self, ext)
        File "C:\Users\Maaz Shahid\AppData\Local\Temp\pip-build-env-qvdwaw5u\overlay\Lib\site-packages\setuptools\_distutils\command\build_ext.py", line 547, in build_extension
          objects = self.compiler.compile(
        File "C:\Users\Maaz Shahid\AppData\Local\Temp\pip-build-env-qvdwaw5u\overlay\Lib\site-packages\setuptools\_distutils\_msvccompiler.py", line 344, in compile
          self.initialize()
        File "C:\Users\Maaz Shahid\AppData\Local\Temp\pip-build-env-qvdwaw5u\overlay\Lib\site-packages\setuptools\_distutils\_msvccompiler.py", line 253, in initialize
          vc_env = _get_vc_env(plat_spec)
        File "C:\Users\Maaz Shahid\AppData\Local\Temp\pip-build-env-qvdwaw5u\overlay\Lib\site-packages\setuptools\msvc.py", line 214, in msvc14_get_vc_env
          return _msvc14_get_vc_env(plat_spec)
        File "C:\Users\Maaz Shahid\AppData\Local\Temp\pip-build-env-qvdwaw5u\overlay\Lib\site-packages\setuptools\msvc.py", line 168, in _msvc14_get_vc_env
          raise distutils.errors.DistutilsPlatformError(
      distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
      error: Support for editable installs via PEP 660 was recently introduced
      in `setuptools`. If you are seeing this error, please report to:

      https://github.com/pypa/setuptools/issues

      Meanwhile you can try the legacy behavior by setting an
      environment variable and trying to install again:

      SETUPTOOLS_ENABLE_FEATURES="legacy-editable"
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building editable for obspy
Failed to build obspy
ERROR: Could not build wheels for obspy, which is required to install pyproject.toml-based projects

我需要这个特殊的修改模块,这里是 github 回购链接: https://github.com/isas-yamamoto/obspy/tree/feature/alsep_format_support

注意:这个修改后的 repo 是原始 repo 的 master 后面的许多提交

看起来您是 pip 将所有内容安装到您的 windows 机器上的主 python 并且软件包可能具有冲突的依赖项。 扩展我在原始帖子中的评论,我建议在安装 python 模块时使用虚拟环境以避免这种头痛。 这是一个链接,显示了隔离虚拟环境的多种方法。 还有一个早于pip的 conda,它具有隔离和 python 模块管理一体化,但是对于您看到的这个错误,我将举一个 python 模块 venv 的示例。 现在我可以使用命令提示符举例。 打开命令提示符并创建一个可以在文件资源管理器中轻松访问的新文件夹:

C:\Users\kyrlon>cd Documents
C:\Users\kyrlon\Documents>mkdir obspy_example && cd obspy_example
C:\Users\kyrlon\Documents\obspy_example>

接下来在这个目录下创建一个 python 虚拟环境:

py -m venv py_venv && .\py_venv\Scripts\activate.bat && py -m pip install -e git+https://github.com/isas-yamamoto/obspy.git#egg=obspy

此目录现在包含一个隔离的 Python。 当 Python 环境的名称出现在(括号)中时,您就知道自己在其中:

(py_venv) C:\Users\kyrlon\Documents\obspy_example>

在同一目录中创建文件demo_obspy.py 如果难以搜索当前目录,可以从命令提示符打开文件资源管理器:

(py_venv) C:\Users\kyrlon\Documents\obspy_example> explorer .

接下来使用选择的代码编辑器打开:

from obspy import read

print("hello for obspy")

现在回到你的命令提示符,运行 python 如下:

(py_venv) C:\Users\kyrlon\Documents\obspy_example> py demo_obspy.py

您现在应该有 output:

hello for obspy

没有错误

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM