安装软件时,我多次发现以下错误:
$ sudo python setup.py install
Traceback (most recent call last):
File "setup.py", line 24, in <module>
from software_name import PACKAGE_NAME
File "/home/username/Softwares/software_name/__init__.py", line 29, in <module>
import scipy
ImportError: No module named scipy
我可以使用例如来安装许多缺失的模块sudo apt-get install -y python-numpy
,但有时我会得到:
username@username:~/Softwares/software_name$ sudo apt-get install -y python-scipy
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package python-scipy is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'python-scipy' has no installation candidate
我真的不知道发生了什么事?我已经读过了另一个线程20.04 LTS 存储库有 NumPy,但没有 SciPy。
编辑:
$ sudo apt install python-pip
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package python-pip is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
python3-pip
E: Package 'python-pip' has no installation candidate
$ pip install scipy
Requirement already satisfied: scipy in /usr/lib/python3/dist-packages (1.3.3)
$ sudo apt install python3-pip
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3-pip is already the newest version (20.0.2-5ubuntu1.6).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
$ sudo pip install scipy
[sudo] password for user_name:
Requirement already satisfied: scipy in /usr/lib/python3/dist-packages (1.3.3)
$ python --version
Python 2.7.18
答案1
在 ubuntu 存储库中查找软件包的最佳来源是packages.ubuntu.com
你可以搜索 scipy并且会看到,它是从 18.04 之后取出的universe
。
我只能推测原因,也许找不到该软件包的维护者。
但是,您可以通过以下方式轻松安装它pip
:
sudo apt install python3-pip
pip install scipy
注意,这pip
将默认安装软件包到您的本地用户。如果您需要python
与sudo
其他用户一起运行脚本,则需要使用以下命令在系统范围内安装它:
sudo pip install scipy
如果你python
仍然无法识别该包,你可能需要检查是否python
有链接到python2
。使用 进行检查python --version
。