0

I'm trying to install the spacepy package on Pycharm (Mac), but the installation keeps failing.

note: This error originates from a subprocess, and is unlikely a problem with pip

Console output:

Collecting spacepy
  Using cached spacepy-0.3.0.zip (19.8 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Collecting h5py>=2.6
  Using cached h5py-3.7.0-cp310-cp310-macosx_10_9_x86_64.whl (3.2 MB)
Requirement already satisfied: scipy>=0.11 in ./venv/lib/python3.10/site-packages (from spacepy) (1.8.1)
Requirement already satisfied: numpy!=1.15.0,>=1.10 in ./venv/lib/python3.10/site-packages (from spacepy) (1.22.4)
Requirement already satisfied: python-dateutil>=1.4 in ./venv/lib/python3.10/site-packages (from spacepy) (2.8.2)
Requirement already satisfied: matplotlib>=1.5 in ./venv/lib/python3.10/site-packages (from spacepy) (3.5.2)
Requirement already satisfied: pillow>=6.2.0 in ./venv/lib/python3.10/site-packages (from matplotlib>=1.5->spacepy) (9.1.1)
Requirement already satisfied: fonttools>=4.22.0 in ./venv/lib/python3.10/site-packages (from matplotlib>=1.5->spacepy) (4.33.3)
Requirement already satisfied: packaging>=20.0 in ./venv/lib/python3.10/site-packages (from matplotlib>=1.5->spacepy) (21.3)
Requirement already satisfied: pyparsing>=2.2.1 in ./venv/lib/python3.10/site-packages (from matplotlib>=1.5->spacepy) (3.0.9)
Requirement already satisfied: cycler>=0.10 in ./venv/lib/python3.10/site-packages (from matplotlib>=1.5->spacepy) (0.11.0)
Requirement already satisfied: kiwisolver>=1.0.1 in ./venv/lib/python3.10/site-packages (from matplotlib>=1.5->spacepy) (1.4.2)
Requirement already satisfied: six>=1.5 in ./venv/lib/python3.10/site-packages (from python-dateutil>=1.4->spacepy) (1.16.0)
Building wheels for collected packages: spacepy
  Building wheel for spacepy (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Building wheel for spacepy (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [188 lines of output]
      running bdist_wheel
      running build
      INFO: C compiler: clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch arm64 -arch x86_64 -g
      
      creating build
      creating build/temp.macosx-10.9-universal2-3.10
      creating build/temp.macosx-10.9-universal2-3.10/spacepy
      creating build/temp.macosx-10.9-universal2-3.10/spacepy/libspacepy
      INFO: compile options: '-c'
      INFO: clang: spacepy/libspacepy/toolbox.c
      INFO: clang: spacepy/libspacepy/randomkit.c
      INFO: clang: spacepy/libspacepy/cn_solver.c
      INFO: clang: spacepy/libspacepy/ctrace2d.c
      INFO: clang: spacepy/libspacepy/poppy.c
      creating build/lib
      creating build/lib/spacepy
      INFO: clang -bundle -undefined dynamic_lookup -arch arm64 -arch x86_64 -g build/temp.macosx-10.9-universal2-3.10/spacepy/libspacepy/toolbox.o build/temp.macosx-10.9-universal2-3.10/spacepy/libspacepy/randomkit.o build/temp.macosx-10.9-universal2-3.10/spacepy/libspacepy/cn_solver.o build/temp.macosx-10.9-universal2-3.10/spacepy/libspacepy/ctrace2d.o build/temp.macosx-10.9-universal2-3.10/spacepy/libspacepy/poppy.o -lm -o build/lib/spacepy/libspacepy.so
      running config_fc
      INFO: unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
      running config_cc
      INFO: unifing config_cc, config, build_clib, build_ext, build commands --compiler options
      running build_py

      INFO: customize Gnu95FCompiler
      WARN: Could not locate executable gfortran
      WARN: Could not locate executable f95
      Traceback (most recent call last):
        File "/Users/nquartey/PycharmProjects/pythonProject/venv/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 363, in <module>
          main()
        File "/Users/nquartey/PycharmProjects/pythonProject/venv/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 345, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/Users/nquartey/PycharmProjects/pythonProject/venv/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py", line 261, in build_wheel
          return _build_backend().build_wheel(wheel_directory, config_settings,
        File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/build_meta.py", line 221, in build_wheel
          return self._build_with_temp_dir(['bdist_wheel'], '.whl',
        File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/build_meta.py", line 207, in _build_with_temp_dir
          self.run_setup()
        File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/build_meta.py", line 258, in run_setup
          super(_BuildMetaLegacyBackend,
        File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/build_meta.py", line 150, in run_setup
          exec(compile(code, __file__, 'exec'), locals())
        File "setup.py", line 950, in <module>
          setup(**setup_kwargs)
        File "/private/var/folders/62/c7kp5v4x5s39gykb57h2t7_m0000gs/T/pip-build-env-k4szbbs7/overlay/lib/python3.10/site-packages/numpy/distutils/core.py", line 169, in setup
          return old_setup(**new_attr)
        File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/__init__.py", line 153, in setup
          return distutils.core.setup(**attrs)
        File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 148, in setup
          dist.run_commands()
        File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 967, in run_commands
          self.run_command(cmd)
        File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 986, in run_command
          cmd_obj.run()
        File "/private/var/folders/62/c7kp5v4x5s39gykb57h2t7_m0000gs/T/pip-build-env-k4szbbs7/overlay/lib/python3.10/site-packages/wheel/bdist_wheel.py", line 299, in run
          self.run_command('build')
        File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 313, in run_command
          self.distribution.run_command(command)
        File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 986, in run_command
          cmd_obj.run()
        File "setup.py", line 733, in run
          self.compile_irbempy()
        File "setup.py", line 507, in compile_irbempy
          f2py_env, fcompexec = f2py_options(fcompiler, self.distribution)
        File "setup.py", line 200, in f2py_options
          fcomp.customize(dist)
        File "/private/var/folders/62/c7kp5v4x5s39gykb57h2t7_m0000gs/T/pip-build-env-k4szbbs7/overlay/lib/python3.10/site-packages/numpy/distutils/fcompiler/__init__.py", line 457, in customize
          self.find_executables()
        File "/private/var/folders/62/c7kp5v4x5s39gykb57h2t7_m0000gs/T/pip-build-env-k4szbbs7/overlay/lib/python3.10/site-packages/numpy/distutils/fcompiler/__init__.py", line 346, in find_executables
          raise CompilerNotFound('%s: f90 nor f77' % ctype)
      numpy.distutils.fcompiler.CompilerNotFound: gnu95: f90 nor f77
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for spacepy
Failed to build spacepy
ERROR: Could not build wheels for spacepy, which is required to install pyproject.toml-based projects

What can I do to get past this issue? Here's what I've tried in the Python and Mac terminals, but I still receive the message above:

pip install spacepy
pip install --no-cache-dir spacepy 
pip install --upgrade pip
pip install --upgrade setuptools
pip install --upgrade wheel
pip install spacepy --user
pip install --no-cache-dir spacepy

I'm a new Mac user, so if anything can be dumbed down for me that would be greatly appreciated. Also, please let me know if there's any information you may need me to include.

moken
  • 3,227
  • 8
  • 13
  • 23
nq209
  • 11
  • 1
  • 2
  • Please [edit] the question and add the full formatted text of the error message. – phd May 24 '22 at 19:52
  • 1
    Sorry about that. I've edited the text of the error message – nq209 May 25 '22 at 11:16
  • SpacePy currently [doesn't provide binary wheels](https://pypi.org/project/spacepy/0.3.0/#files) for MacOS X so `pip` tried to compile from sources and failed not founding a Fortran compiler. Try to install with Anaconda. See https://spacepy.github.io/install.html, https://spacepy.github.io/install_mac.html and https://spacepy.github.io/install_linux.html – phd May 25 '22 at 21:50
  • 1
    I installed a Fortran compiler and now it's working. Thank you! – nq209 May 26 '22 at 17:09

2 Answers2

0

If you are using MacOS or Windows, try installing gfortran.

(If you are using Linux, try installing gcc-fortran)

0

For Mac, there is a possible workaround for this problem if you use Conda. The idea is to create an x86 environment on the Mac and do your pip install after that.

conda create -n <name>
conda activate <name>
conda config --env --set subdir osx-64
conda install python=3.8

Here I choose Python 3.8, but you can choose another version.