Search code examples
pythonnumpyinstallationpippackage

Installing pyshtools with pip ModuleNotFoundError: No module named 'numpy' although numpy is installed


I want to create a new environment using pip's 'venv' containing the package "pyshtools". When installing pyshtools with pip it says that numpy is missing, however as can be seen below in the console output, numpy should be included in the venv already. Uninstalling numpy for pyshtools to install the dependency on its own does not do the trick either. I would be really grateful if someone could help me out here as i just recently switched from conda environments to pip and may overlook something about pip packaging.

Below is the content of the command prompt.

(.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.

I already tried: Installed and uninstalled numpy and pyshtools seperatly and together in base and venv - both didn't work, same Error. Searched for same problem - unable to find existing solution. Searched for other problems with numpy installation in pip venv context - nothing seeemed to fit.

UPDATE Python 3.12. was the Problem, downgraded to 3.11. and it works just fine. Thanks to user 8349697 for getting me on the right track.


Solution

  • Solution was to downgrade to python 3.11. as there seems to be some issue with pyshtools and python 3.12. - closed.