使用 pip 安装 pyshtools ModuleNotFoundError: 尽管安装了 numpy,但没有名为 'numpy' 的模块

问题描述 投票:0回答:1

我想使用 pip 的“venv”创建一个包含“pyshtools”包的新环境。当使用 pip 安装 pyshtools 时,它表示缺少 numpy,但是从下面的控制台输出中可以看出,numpy 应该已经包含在 venv 中。卸载 pyshtools 的 numpy 以自行安装依赖项也不起作用。如果有人能在这里帮助我,我将非常感激,因为我最近刚刚从 conda 环境切换到 pip,并且可能会忽略有关 pip 打包的一些内容。

以下是命令提示符的内容。

(.venv) C:\Users\Luis-\OneDrive\Dokumente\Tu Braunschweig\Master\3. Semester\Weltraumpraktikum\code\planmaginvbs>pip install pyshtools
Collecting pyshtools
  Downloading pyshtools-4.10.4.tar.gz (38.3 MB)
     ---------------------------------------- 38.3/38.3 MB 9.5 MB/s eta 0:00:00
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [21 lines of output]
      <string>:20: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
      Traceback (most recent call last):
        File "C:\Users\Luis-\OneDrive\Dokumente\Tu Braunschweig\Master\3. Semester\Weltraumpraktikum\code\planmaginvbs\.venv\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
          main()
        File "C:\Users\Luis-\OneDrive\Dokumente\Tu Braunschweig\Master\3. Semester\Weltraumpraktikum\code\planmaginvbs\.venv\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\Luis-\OneDrive\Dokumente\Tu Braunschweig\Master\3. Semester\Weltraumpraktikum\code\planmaginvbs\.venv\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\Luis-\AppData\Local\Temp\pip-build-env-qssgl9gu\overlay\Lib\site-packages\setuptools\build_meta.py", line 325, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\Luis-\AppData\Local\Temp\pip-build-env-qssgl9gu\overlay\Lib\site-packages\setuptools\build_meta.py", line 295, in _get_build_requires
          self.run_setup()
        File "C:\Users\Luis-\AppData\Local\Temp\pip-build-env-qssgl9gu\overlay\Lib\site-packages\setuptools\build_meta.py", line 480, in run_setup
          super(_BuildMetaLegacyBackend, self).run_setup(setup_script=setup_script)
        File "C:\Users\Luis-\AppData\Local\Temp\pip-build-env-qssgl9gu\overlay\Lib\site-packages\setuptools\build_meta.py", line 311, in run_setup
          exec(code, locals())
        File "<string>", line 24, in <module>
      ModuleNotFoundError: No module named 'numpy'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

(.venv) C:\Users\Luis-\OneDrive\Dokumente\Tu Braunschweig\Master\3. Semester\Weltraumpraktikum\code\planmaginvbs>pip install numpy
Collecting numpy
  Downloading numpy-1.26.3-cp312-cp312-win_amd64.whl.metadata (61 kB)
     ---------------------------------------- 61.2/61.2 kB 407.8 kB/s eta 0:00:00
Downloading numpy-1.26.3-cp312-cp312-win_amd64.whl (15.5 MB)
   ---------------------------------------- 15.5/15.5 MB 10.1 MB/s eta 0:00:00
Installing collected packages: numpy
Successfully installed numpy-1.26.3

(.venv) C:\Users\Luis-\OneDrive\Dokumente\Tu Braunschweig\Master\3. Semester\Weltraumpraktikum\code\planmaginvbs>pip install pyshtools
Collecting pyshtools
  Using cached pyshtools-4.10.4.tar.gz (38.3 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [21 lines of output]
      <string>:20: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
      Traceback (most recent call last):
        File "C:\Users\Luis-\OneDrive\Dokumente\Tu Braunschweig\Master\3. Semester\Weltraumpraktikum\code\planmaginvbs\.venv\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
          main()
        File "C:\Users\Luis-\OneDrive\Dokumente\Tu Braunschweig\Master\3. Semester\Weltraumpraktikum\code\planmaginvbs\.venv\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\Luis-\OneDrive\Dokumente\Tu Braunschweig\Master\3. Semester\Weltraumpraktikum\code\planmaginvbs\.venv\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 118, in get_requires_for_build_wheel
          return hook(config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\Luis-\AppData\Local\Temp\pip-build-env-u2xqdbed\overlay\Lib\site-packages\setuptools\build_meta.py", line 325, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=['wheel'])
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\Luis-\AppData\Local\Temp\pip-build-env-u2xqdbed\overlay\Lib\site-packages\setuptools\build_meta.py", line 295, in _get_build_requires
          self.run_setup()
        File "C:\Users\Luis-\AppData\Local\Temp\pip-build-env-u2xqdbed\overlay\Lib\site-packages\setuptools\build_meta.py", line 480, in run_setup
          super(_BuildMetaLegacyBackend, self).run_setup(setup_script=setup_script)
        File "C:\Users\Luis-\AppData\Local\Temp\pip-build-env-u2xqdbed\overlay\Lib\site-packages\setuptools\build_meta.py", line 311, in run_setup
          exec(code, locals())
        File "<string>", line 24, in <module>
      ModuleNotFoundError: No module named 'numpy'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.

我已经尝试过: 分别在 base 和 venv 中安装和卸载 numpy 和 pyshtools - 两者都不起作用,同样的错误。 搜索相同的问题 - 无法找到现有的解决方案。 在 pip venv 上下文中搜索 numpy 安装的其他问题 - 似乎没有合适的。

更新 Python 3.12。是问题,降级到 3.11。而且效果很好。感谢用户8349697让我走上正轨。

python numpy installation pip package
1个回答
0
投票

解决方案是降级到 python 3.11。因为 pyshtools 和 python 3.12 似乎存在一些问题。 - 关闭。

© www.soinside.com 2019 - 2024. All rights reserved.