在Pycharm (Mac)上安装spacepy时出现 pip错误



我试图在Pycharm (Mac)上安装spacepy包,但安装总是失败。

注意:此错误源自子进程,不太可能是pip的问题。

控制台输出:

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

我能做些什么来克服这个问题?以下是我在Python和Mac终端中尝试的,但我仍然收到上面的消息:

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

我是一个新的Mac用户,所以如果有什么可以为我简化,我将不胜感激。此外,如果您需要我提供任何信息,请告诉我。

如果您使用的是MacOS或Windows,请尝试安装gfortran。

(如果您使用的是Linux,请尝试安装gcc-fortran)

对于Mac,如果您使用Conda,则有可能解决此问题。这个想法是在Mac上创建一个x86环境,然后进行pip安装。

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

这里我选择Python 3.8,但你可以选择其他版本。

相关内容

  • 没有找到相关文章

最新更新