尽管设置了环境变量,但安装FSPS会引发错误

时间:2019-11-28 14:56:12

标签: python pip

我正在尝试使用pip安装fsps库。我在Fedora 30上使用Python 3.7.5和pip 19.3.1。 我已按照here的说明安装了FSPS,并已安装numpy。但是当我跑步

pip3 install fsps

我收到以下错误

Collecting fsps
  Using cached https://files.pythonhosted.org/packages/3d/4f/3491667b60f9e202bf755c18e6e03048bd003c4b9b33dd832c446171d940/fsps-0.2.2.tar.gz
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-smda6ikh/fsps/setup.py'"'"'; __file__='"'"'/tmp/pip-install-smda6ikh/fsps/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-smda6ikh/fsps/pip-egg-info
         cwd: /tmp/pip-install-smda6ikh/fsps/
    Complete output (16 lines):
    Traceback (most recent call last):
      File "/tmp/pip-install-smda6ikh/fsps/fsps/__init__.py", line 26, in <module>
        ev = os.environ["SPS_HOME"]
      File "/usr/lib64/python3.7/os.py", line 679, in __getitem__
        raise KeyError(key) from None
    KeyError: 'SPS_HOME'

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-smda6ikh/fsps/setup.py", line 87, in <module>
        from fsps import __version__  # NOQA
      File "/tmp/pip-install-smda6ikh/fsps/fsps/__init__.py", line 28, in <module>
        raise ImportError("You need to have the SPS_HOME environment variable")
    ImportError: You need to have the SPS_HOME environment variable
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

我确实将SPS_HOME=/path/to/fsps/export SPS_HOME添加到了.bashrc中,并且已编译的.o.mod文件位于${SPS_HOME}/src中。 echo $SPS_HOME确实显示了路径。


我尝试从source安装。正在运行

git clone https://github.com/dfm/python-fsps.git
cd python-fsps
python setup.py install

引发同样的错误

Traceback (most recent call last):
  File "/home/user/python-fsps/fsps/__init__.py", line 26, in <module>
    ev = os.environ["SPS_HOME"]
  File "/usr/lib64/python3.7/os.py", line 679, in __getitem__
    raise KeyError(key) from None
KeyError: 'SPS_HOME'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "setup.py", line 87, in <module>
    from fsps import __version__  # NOQA
  File "/home/user/python-fsps/fsps/__init__.py", line 28, in <module>
    raise ImportError("You need to have the SPS_HOME environment variable")
ImportError: You need to have the SPS_HOME environment variable

如何解决此错误并安装FSPS?

1 个答案:

答案 0 :(得分:1)

  

我确实将SPS_HOME=/path/to/fsps/添加到了.bashrc

应该将环境变量添加到~/.bash_profile中(尽管~/.bashrc也可以容忍)。

要使环境变量在子流程中可见,必须将其导出。设置变量后添加:

export SPS_HOME