Ubuntu 16.04 に scipy と numpy をインストールしようとしているのですが、次のエラーが繰り返し発生します。依存関係のインストール方法を教えてください。
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
python-numpy : Depends: python:any (>= 2.7.5-5~)
E: Unable to correct problems, you have held broken packages.
答え1
pip (代替 Python パッケージ インストーラー) を使用して、システム全体に numpy と scipy をインストールすることもできます。
sudo apt-get install python-pip
sudo pip install numpy scipy
これにより、Ubuntu パッケージ マネージャーの依存関係エラーに関係なくインストールできるようになります。
答え2
現在サポートされているすべてのバージョンの Ubuntu に依存関係をインストールするには、ターミナルを開いて次のコマンドを入力します。
sudo apt update
sudo apt install --no-install-recommends python2.7-minimal python2.7
sudo apt install python-numpy # in Ubuntu 20.04 and earlier
sudo apt install python-scipy # in Ubuntu 18.04 and earlier
Python 3.xの場合
sudo apt update
sudo apt install --no-install-recommends python3-minimal python3
sudo apt install python3-numpy python3-scipy
答え3
私の場合、scipy をグローバルではなく仮想環境にインストールしたかったのです。pip install の前に libatlas-base-dev と gfortran をインストールすることで問題は解決しました。
sudo apt-get install libatlas-base-dev
sudo apt-get install gfortran
source .venv/bin/activate
pip install scipy