我在将 python 包 PyTransit 和 ktransit 安装到 Anaconda 3(在 Linux 上)时遇到问题。似乎很多其他人都有类似的错误,但他们的解决方案都没有对我有用。发生了一堆事情:
pip install ktransit
给出:
/usr/bin/ld: /home/name/anaconda3/lib/libgfortran.a(pause.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
/home/name/anaconda3/lib/libgfortran.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
我会尝试将 ./configure 与 --enable-shared 一起使用,但没有配置文件。我尝试添加extra_compile_args = ["-fPIC"], extra_link_args=["-fPIC"]
到 setup.py (如https://github.com/h5py/h5py/issues/851),但什么也没做。
pip install pytransit
给出不同的错误:
#warning "Using deprecated NumPy API, disable it by " \
Warning: src/gimenez.f90:35: Illegal preprocessor directive
Warning: src/gimenez.f90:36: Illegal preprocessor directive
Warning: src/gimenez.f90:37: Illegal preprocessor directive
src/gimenez.f90:271.33:
real(8), dimension(CHUNK_SIZE, npol) :: d
1
Error: Symbol 'chunk_size' at (1) has no IMPLICIT type
这就是有趣的地方。使用 pip3(或 sudo pip)允许 ktransit 成功安装,但对 pytransit 没有任何作用。pip 和 pip3 似乎绑定到不同的地方:
which pip
/home/name/anaconda3/bin/pip
which pip3
/usr/local/bin/pip3
which python
/home/name/anaconda3/bin/python
最后,当我尝试通过 anaconda 在 jupyter notebook 中导入 ktransit 时,它会失败,但是当我在 Jupyter QtConsole 中导入 ktransit 时,它会成功,但似乎包含自身并且不提供实际功能。我的意思是我不能引用模块中的任何内容,并且:
Help on package ktransit:
NAME
ktransit
PACKAGE CONTENTS
ktransit (package)
setup
FILE
(built-in)
我在想与 /usr/bin 相关联的任何版本的 python 都会以某种方式困扰我……或者我的 gcc 或 libgfortran 有问题?我有 gcc 版本 4.8.5 和 6(gcc --version 提供 4.8.5,但 -update-alternatives 说只有一个版本,6)。
感谢您花时间阅读本文。如果您有任何建议或想法,我将不胜感激!