I have the need to use the older python 2.7 with numpy for a Spark project on EC2 ubuntu 22.04. These were what I did ...
sudo apt update
sudo apt install python2.7
sudo apt-get install python-numpy
The last step got an error "E: Unable to locate package python-numpy".
Any suggestions on to fix the problem?
Instead of using numpy from the Ubuntu repos - where it is obviously not included any more in Ubuntu 22.04 - you can install first pip via the package
python-pip
and then install via pip numpy.Remember that the numpy project dropped the support for Python 2.7 for numpy 1.7 and newer, thus the highest version you can install is 1.16.6.
So the steps for the installation are:
Please remember that neither Python 2.7 nor numpy 1.16.6 are supported any more, thus there will be not more bug fix releases and any possibly existing vulnerabilities will not be fixed. The support for numpy 1.16.6 was dropped on Jan 1st 2020. The same applies to pip installed from Ubuntu's sources, as the pip project dropped the support for Python 2 as well. pip 20.3, which is the version included in the Ubuntu sources, is the highest version which still support Python 2.
Packages installed via apt that come from Ubuntu's official repositories are more secure than pip packages that come from PyPI, which is a public repository where anyone can upload packages. To install the python-numpy package from Ubuntu 20.04 in Ubuntu 22.04 open the terminal and type: