安装软件后,我多次发现以下错误:
$ 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
在 ubuntu 存储库中查找包的最佳来源是packages.ubuntu.com
你可以搜索 scipy
universe
会看到,它是从18.04 之后取出的。我只能推测原因,也许找不到该软件包的维护者。
但是,您可以通过以下方式轻松安装它
pip
:请注意,这
pip
将默认为您的本地用户安装软件包。如果您需要与其他用户或其他用户一起运行python
脚本sudo
,则需要在系统范围内安装它:如果您
python
仍然无法识别包裹,您可能需要检查是否python
有链接到python2
. 检查与python --version
。