抱歉,您的瀏覽器無法訪問本站
本頁面需要瀏覽器支持(啟用)JavaScript
了解詳情 >

最近在個人電腦上安裝21cmFAST宇宙學演化模擬程序,這裡簡要記錄安裝過程以及遇到的問題:

首先安裝conda環境

1
2
# 我的系統是Arch linux
yay -S miniconda3

安裝後發現找不到conda命令,檢查才知道環境變數設置不對,可以直接編輯.bashrc文件,我使用的是zsh終端,因此我修改.zshrc,文件最後加環境變數:

1
export PATH="/opt/miniconda3/bin:$PATH"

然後別忘記運行:

1
source .zshrc

安裝21cmfast

我這裡安裝的是最新版本的21cmfast:

1
2
3
4
5
6
7
8
# 我這裡的python版本是3.13,目前最新版本的21cmfast是3.4,python版本不能低於3.11
conda create -n 21cmfast

# 進入虛擬環境
conda activate 21cmfast

# 安裝
pip install 21cmfast

進行到這裡發生了報錯:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
Building wheels for collected packages: 21cmfast, cosmotile
Building wheel for 21cmfast (pyproject.toml) ... error
error: subprocess-exited-with-error

× Building wheel for 21cmfast (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [213 lines of output]
/tmp/pip-build-env-t5twjizk/overlay/lib/python3.12/site-packages/setuptools_scm/_integration/setuptools.py:92: UserWarning: version of 21cmFAST already set
warnings.warn(f"version of {dist_name} already set")
/tmp/pip-build-env-t5twjizk/normal/lib/python3.12/site-packages/cffi/cparser.py:163: UserWarning: Global variable 'photon_cons_allocated' in cdef(): for consistency with C it should have a storage class specifier (usually 'extern')
warnings.warn("Global variable '%s' in cdef(): for consistency "
/tmp/pip-build-env-t5twjizk/normal/lib/python3.12/site-packages/cffi/cparser.py:163: UserWarning: Global variable 'interpolation_tables_allocated' in cdef(): for consistency with C it should have a storage class specifier (usually 'extern')
warnings.warn("Global variable '%s' in cdef(): for consistency "
/tmp/pip-build-env-t5twjizk/overlay/lib/python3.12/site-packages/setuptools/dist.py:759: SetuptoolsDeprecationWarning: License classifiers are deprecated.
!!

********************************************************************************
Please consider removing the following classifiers in favor of a SPDX license expression:

License :: OSI Approved :: MIT License

See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license for details.
********************************************************************************

!!
self._finalize_license_expression()
running bdist_wheel
running build
running build_py
creating build/lib.linux-x86_64-cpython-312/py21cmfast
copying src/py21cmfast/yaml.py -> build/lib.linux-x86_64-cpython-312/py21cmfast
copying src/py21cmfast/wrapper.py -> build/lib.linux-x86_64-cpython-312/py21cmfast
copying src/py21cmfast/plotting.py -> build/lib.linux-x86_64-cpython-312/py21cmfast
copying src/py21cmfast/outputs.py -> build/lib.linux-x86_64-cpython-312/py21cmfast
copying src/py21cmfast/lightcones.py -> build/lib.linux-x86_64-cpython-312/py21cmfast
copying src/py21cmfast/inputs.py -> build/lib.linux-x86_64-cpython-312/py21cmfast
copying src/py21cmfast/cli.py -> build/lib.linux-x86_64-cpython-312/py21cmfast
copying src/py21cmfast/cache_tools.py -> build/lib.linux-x86_64-cpython-312/py21cmfast
copying src/py21cmfast/_version.py -> build/lib.linux-x86_64-cpython-312/py21cmfast
copying src/py21cmfast/_utils.py -> build/lib.linux-x86_64-cpython-312/py21cmfast
copying src/py21cmfast/_logging.py -> build/lib.linux-x86_64-cpython-312/py21cmfast
copying src/py21cmfast/_cfg.py -> build/lib.linux-x86_64-cpython-312/py21cmfast
copying src/py21cmfast/__init__.py -> build/lib.linux-x86_64-cpython-312/py21cmfast
creating build/lib.linux-x86_64-cpython-312/py21cmfast/_data
copying src/py21cmfast/_data/__init__.py -> build/lib.linux-x86_64-cpython-312/py21cmfast/_data
running egg_info
writing src/21cmFAST.egg-info/PKG-INFO
writing dependency_links to src/21cmFAST.egg-info/dependency_links.txt
writing entry points to src/21cmFAST.egg-info/entry_points.txt
writing requirements to src/21cmFAST.egg-info/requires.txt
writing top-level names to src/21cmFAST.egg-info/top_level.txt
ERROR setuptools_scm._file_finders.git listing git files failed - pretending there aren't any
reading manifest file 'src/21cmFAST.egg-info/SOURCES.txt'
adding license file 'LICENSE'
adding license file 'AUTHORS.rst'
writing manifest file 'src/21cmFAST.egg-info/SOURCES.txt'
/tmp/pip-build-env-t5twjizk/overlay/lib/python3.12/site-packages/setuptools/command/build_py.py:212: _Warning: Package 'py21cmfast._data.x_int_tables' is absent from the `packages` configuration.
!!

********************************************************************************
############################
# Package would be ignored #
############################
Python recognizes 'py21cmfast._data.x_int_tables' as an importable package[^1],
but it is absent from setuptools' `packages` configuration.

This leads to an ambiguous overall configuration. If you want to distribute this
package, please make sure that 'py21cmfast._data.x_int_tables' is explicitly added
to the `packages` configuration field.

Alternatively, you can also rely on setuptools' discovery methods
(for example by using `find_namespace_packages(...)`/`find_namespace:`
instead of `find_packages(...)`/`find:`).

You can read more about "package discovery" on setuptools documentation page:

- https://setuptools.pypa.io/en/latest/userguide/package_discovery.html

If you don't want 'py21cmfast._data.x_int_tables' to be distributed and are
already explicitly excluding 'py21cmfast._data.x_int_tables' via
`find_namespace_packages(...)/find_namespace` or `find_packages(...)/find`,
you can try to use `exclude_package_data`, or `include-package-data=False` in
combination with a more fine grained `package-data` configuration.

You can read more about "package data files" on setuptools documentation page:

- https://setuptools.pypa.io/en/latest/userguide/datafiles.html


[^1]: For Python, any directory (with suitable naming) can be imported,
even if it does not contain any `.py` files.
On the other hand, currently there is no concept of package data
directory, all directories are treated like packages.
********************************************************************************

!!
check.warn(importable)
/tmp/pip-build-env-t5twjizk/overlay/lib/python3.12/site-packages/setuptools/command/build_py.py:212: _Warning: Package 'py21cmfast.src' is absent from the `packages` configuration.
!!

********************************************************************************
############################
# Package would be ignored #
############################
Python recognizes 'py21cmfast.src' as an importable package[^1],
but it is absent from setuptools' `packages` configuration.

This leads to an ambiguous overall configuration. If you want to distribute this
package, please make sure that 'py21cmfast.src' is explicitly added
to the `packages` configuration field.

Alternatively, you can also rely on setuptools' discovery methods
(for example by using `find_namespace_packages(...)`/`find_namespace:`
instead of `find_packages(...)`/`find:`).

You can read more about "package discovery" on setuptools documentation page:

- https://setuptools.pypa.io/en/latest/userguide/package_discovery.html

If you don't want 'py21cmfast.src' to be distributed and are
already explicitly excluding 'py21cmfast.src' via
`find_namespace_packages(...)/find_namespace` or `find_packages(...)/find`,
you can try to use `exclude_package_data`, or `include-package-data=False` in
combination with a more fine grained `package-data` configuration.

You can read more about "package data files" on setuptools documentation page:

- https://setuptools.pypa.io/en/latest/userguide/datafiles.html


[^1]: For Python, any directory (with suitable naming) can be imported,
even if it does not contain any `.py` files.
On the other hand, currently there is no concept of package data
directory, all directories are treated like packages.
********************************************************************************

!!
check.warn(importable)
creating build/lib.linux-x86_64-cpython-312/py21cmfast/src
copying src/py21cmfast/src/21cmFAST.h -> build/lib.linux-x86_64-cpython-312/py21cmfast/src
copying src/py21cmfast/src/BrightnessTemperatureBox.c -> build/lib.linux-x86_64-cpython-312/py21cmfast/src
copying src/py21cmfast/src/Constants.h -> build/lib.linux-x86_64-cpython-312/py21cmfast/src
copying src/py21cmfast/src/FindHaloes.c -> build/lib.linux-x86_64-cpython-312/py21cmfast/src
copying src/py21cmfast/src/GenerateICs.c -> build/lib.linux-x86_64-cpython-312/py21cmfast/src
copying src/py21cmfast/src/Globals.h -> build/lib.linux-x86_64-cpython-312/py21cmfast/src
copying src/py21cmfast/src/IonisationBox.c -> build/lib.linux-x86_64-cpython-312/py21cmfast/src
copying src/py21cmfast/src/PerturbField.c -> build/lib.linux-x86_64-cpython-312/py21cmfast/src
copying src/py21cmfast/src/PerturbHaloField.c -> build/lib.linux-x86_64-cpython-312/py21cmfast/src
copying src/py21cmfast/src/SpinTemperatureBox.c -> build/lib.linux-x86_64-cpython-312/py21cmfast/src
copying src/py21cmfast/src/UsefulFunctions.c -> build/lib.linux-x86_64-cpython-312/py21cmfast/src
copying src/py21cmfast/src/bubble_helper_progs.c -> build/lib.linux-x86_64-cpython-312/py21cmfast/src
copying src/py21cmfast/src/cexcept.h -> build/lib.linux-x86_64-cpython-312/py21cmfast/src
copying src/py21cmfast/src/dft.c -> build/lib.linux-x86_64-cpython-312/py21cmfast/src
copying src/py21cmfast/src/elec_interp.c -> build/lib.linux-x86_64-cpython-312/py21cmfast/src
copying src/py21cmfast/src/exceptions.h -> build/lib.linux-x86_64-cpython-312/py21cmfast/src
copying src/py21cmfast/src/heating_helper_progs.c -> build/lib.linux-x86_64-cpython-312/py21cmfast/src
copying src/py21cmfast/src/indexing.c -> build/lib.linux-x86_64-cpython-312/py21cmfast/src
copying src/py21cmfast/src/logger.h -> build/lib.linux-x86_64-cpython-312/py21cmfast/src
copying src/py21cmfast/src/ps.c -> build/lib.linux-x86_64-cpython-312/py21cmfast/src
copying src/py21cmfast/src/recombinations.c -> build/lib.linux-x86_64-cpython-312/py21cmfast/src
copying src/py21cmfast/src/subcell_rsds.c -> build/lib.linux-x86_64-cpython-312/py21cmfast/src
copying src/py21cmfast/_data/Lyman_alpha_heating_table.dat -> build/lib.linux-x86_64-cpython-312/py21cmfast/_data
copying src/py21cmfast/_data/Transfers_z0.dat -> build/lib.linux-x86_64-cpython-312/py21cmfast/_data
copying src/py21cmfast/_data/kappa_eH_table.dat -> build/lib.linux-x86_64-cpython-312/py21cmfast/_data
copying src/py21cmfast/_data/kappa_pH_table.dat -> build/lib.linux-x86_64-cpython-312/py21cmfast/_data
copying src/py21cmfast/_data/recfast_LCDM.dat -> build/lib.linux-x86_64-cpython-312/py21cmfast/_data
copying src/py21cmfast/_data/stellar_spectra.dat -> build/lib.linux-x86_64-cpython-312/py21cmfast/_data
creating build/lib.linux-x86_64-cpython-312/py21cmfast/_data/x_int_tables
copying src/py21cmfast/_data/x_int_tables/log_xi_-1.0.dat -> build/lib.linux-x86_64-cpython-312/py21cmfast/_data/x_int_tables
copying src/py21cmfast/_data/x_int_tables/log_xi_-1.3.dat -> build/lib.linux-x86_64-cpython-312/py21cmfast/_data/x_int_tables
copying src/py21cmfast/_data/x_int_tables/log_xi_-1.6.dat -> build/lib.linux-x86_64-cpython-312/py21cmfast/_data/x_int_tables
copying src/py21cmfast/_data/x_int_tables/log_xi_-2.0.dat -> build/lib.linux-x86_64-cpython-312/py21cmfast/_data/x_int_tables
copying src/py21cmfast/_data/x_int_tables/log_xi_-2.3.dat -> build/lib.linux-x86_64-cpython-312/py21cmfast/_data/x_int_tables
copying src/py21cmfast/_data/x_int_tables/log_xi_-2.6.dat -> build/lib.linux-x86_64-cpython-312/py21cmfast/_data/x_int_tables
copying src/py21cmfast/_data/x_int_tables/log_xi_-3.0.dat -> build/lib.linux-x86_64-cpython-312/py21cmfast/_data/x_int_tables
copying src/py21cmfast/_data/x_int_tables/log_xi_-3.3.dat -> build/lib.linux-x86_64-cpython-312/py21cmfast/_data/x_int_tables
copying src/py21cmfast/_data/x_int_tables/log_xi_-3.6.dat -> build/lib.linux-x86_64-cpython-312/py21cmfast/_data/x_int_tables
copying src/py21cmfast/_data/x_int_tables/log_xi_-4.0.dat -> build/lib.linux-x86_64-cpython-312/py21cmfast/_data/x_int_tables
copying src/py21cmfast/_data/x_int_tables/xi_0.500.dat -> build/lib.linux-x86_64-cpython-312/py21cmfast/_data/x_int_tables
copying src/py21cmfast/_data/x_int_tables/xi_0.900.dat -> build/lib.linux-x86_64-cpython-312/py21cmfast/_data/x_int_tables
copying src/py21cmfast/_data/x_int_tables/xi_0.990.dat -> build/lib.linux-x86_64-cpython-312/py21cmfast/_data/x_int_tables
copying src/py21cmfast/_data/x_int_tables/xi_0.999.dat -> build/lib.linux-x86_64-cpython-312/py21cmfast/_data/x_int_tables
running build_ext
generating cffi module 'build/temp.linux-x86_64-cpython-312/py21cmfast.c_21cmfast.c'
creating build/temp.linux-x86_64-cpython-312
building 'py21cmfast.c_21cmfast' extension
creating build/temp.linux-x86_64-cpython-312/build/temp.linux-x86_64-cpython-312
gcc -pthread -B /opt/miniconda3/compiler_compat -fno-strict-overflow -Wsign-compare -DNDEBUG -O2 -Wall -fPIC -O2 -isystem /opt/miniconda3/include -fPIC -O2 -isystem /opt/miniconda3/include -fPIC -I/tmp/pip-install-a09n5yan/21cmfast_5f9692c395fa45a5952d57195e300800/src/py21cmfast/src -I/opt/miniconda3/include/python3.12 -c build/temp.linux-x86_64-cpython-312/py21cmfast.c_21cmfast.c -o build/temp.linux-x86_64-cpython-312/build/temp.linux-x86_64-cpython-312/py21cmfast.c_21cmfast.o -w --verbose -Ofast -fopenmp
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
Target: x86_64-pc-linux-gnu
Configured with: /build/gcc/src/gcc/configure --enable-languages=ada,c,c++,d,fortran,go,lto,m2,objc,obj-c++,rust,cobol --enable-bootstrap --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://gitlab.archlinux.org/archlinux/packaging/packages/gcc/-/issues --with-build-config=bootstrap-lto --with-linker-hash-style=gnu --with-system-zlib --enable-__cxa_atexit --enable-cet=auto --enable-checking=release --enable-clocale=gnu --enable-default-pie --enable-default-ssp --enable-gnu-indirect-function --enable-gnu-unique-object --enable-libstdcxx-backtrace --enable-link-serialization=1 --enable-linker-build-id --enable-lto --enable-multilib --enable-plugin --enable-shared --enable-threads=posix --disable-libssp --disable-libstdcxx-pch --disable-werror
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 15.1.1 20250425 (GCC)
COLLECT_GCC_OPTIONS='-pthread' '-B' '/opt/miniconda3/compiler_compat' '-fno-strict-overflow' '-Wsign-compare' '-D' 'NDEBUG' '-O2' '-Wall' '-O2' '-isystem' '/opt/miniconda3/include' '-O2' '-isystem' '/opt/miniconda3/include' '-fPIC' '-I' '/tmp/pip-install-a09n5yan/21cmfast_5f9692c395fa45a5952d57195e300800/src/py21cmfast/src' '-I' '/opt/miniconda3/include/python3.12' '-c' '-o' 'build/temp.linux-x86_64-cpython-312/build/temp.linux-x86_64-cpython-312/py21cmfast.c_21cmfast.o' '-w' '-v' '-Ofast' '-fopenmp' '-mtune=generic' '-march=x86-64' '-pthread' '-dumpdir' 'build/temp.linux-x86_64-cpython-312/build/temp.linux-x86_64-cpython-312/'
/usr/lib/gcc/x86_64-pc-linux-gnu/15.1.1/cc1 -quiet -v -I /tmp/pip-install-a09n5yan/21cmfast_5f9692c395fa45a5952d57195e300800/src/py21cmfast/src -I /opt/miniconda3/include/python3.12 -D_REENTRANT -D NDEBUG -isystem /opt/miniconda3/include -isystem /opt/miniconda3/include build/temp.linux-x86_64-cpython-312/py21cmfast.c_21cmfast.c -quiet -dumpdir build/temp.linux-x86_64-cpython-312/build/temp.linux-x86_64-cpython-312/ -dumpbase py21cmfast.c_21cmfast.c -dumpbase-ext .c -mtune=generic -march=x86-64 -O2 -O2 -O2 -Ofast -Wsign-compare -Wall -w -version -fno-strict-overflow -fPIC -fopenmp -o /tmp/ccPKa4H2.s
GNU C23 (GCC) version 15.1.1 20250425 (x86_64-pc-linux-gnu)
compiled by GNU C version 15.1.1 20250425, GMP version 6.3.0, MPFR version 4.2.2, MPC version 1.3.1, isl version isl-0.27-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring duplicate directory "/opt/miniconda3/include"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-pc-linux-gnu/15.1.1/../../../../x86_64-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/tmp/pip-install-a09n5yan/21cmfast_5f9692c395fa45a5952d57195e300800/src/py21cmfast/src
/opt/miniconda3/include/python3.12
/opt/miniconda3/include
/usr/lib/gcc/x86_64-pc-linux-gnu/15.1.1/include
/usr/local/include
/usr/lib/gcc/x86_64-pc-linux-gnu/15.1.1/include-fixed
/usr/include
End of search list.
Compiler executable checksum: 335c205337bb594afdc1dd844ba56be5
In file included from build/temp.linux-x86_64-cpython-312/py21cmfast.c_21cmfast.c:576:
/tmp/pip-install-a09n5yan/21cmfast_5f9692c395fa45a5952d57195e300800/src/py21cmfast/src/GenerateICs.c:13:10: fatal error: gsl/gsl_interp.h: No such file or directory
13 | #include <gsl/gsl_interp.h>
| ^~~~~~~~~~~~~~~~~~
compilation terminated.
error: command '/usr/bin/gcc' failed with exit code 1
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for 21cmfast
Building wheel for cosmotile (pyproject.toml) ... done
Created wheel for cosmotile: filename=cosmotile-0.2.4-py3-none-any.whl size=10921 sha256=fcda4f560c65573e2da29d9ba5f4a5e1e6ff69b16249e26519f5356696605512
Stored in directory: /home/sirius/.cache/pip/wheels/c4/48/de/9ea0d0ccad54ce08f23fa80d0a357f75bc7192c1928ffd22d9
Successfully built cosmotile
Failed to build 21cmfast
ERROR: Failed to build installable wheels for some pyproject.toml based projects (21cmfast)

原因是缺少gsl包(另外還要確保有base-devel包),安裝即可:

1
sudo pacman -S gsl

這樣再次執行pip install 21cmfast就可以了。

最後安裝成功,如果彈出警告:

1
2
3
4
5
6
WARNING: The script f2py is installed in '/home/sirius/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The scripts fits2bitmap, fitscheck, fitsdiff, fitsheader, fitsinfo, samp_hub, showtable, showtable-astropy, volint and wcslint are installed in '/home/sirius/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
WARNING: The script 21cmfast is installed in '/home/sirius/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

錯誤提示表明/home/sirius/.local/bin目錄未加入PATH環境變數,導致以下工具無法直接運行:

  • f2py(NumPy相關工具)
  • fits2bitmap、fitscheck 等(Astropy工具)
  • 21cmfast(主程式)

繼續在.zshrc添加環境變數即可解決警告:

1
2
3
4
# 在兩個export之前最好加
export CRYPTOGRAPHY_OPENSSL_NO_LEGACY=1
# 然後
export PATH="$HOME/.local/bin:$PATH"

參考

評論



Powered by Hexo | Theme keep Volantis

本站總訪問量 總訪客數 🌎