According to https://packages.ubuntu.com/eoan/python-requests, the python-request
package has been dropped after Ubuntu Eoan (19.10)
=> The package is no more available on Ubuntu focal (20.04)
As a consequence you can have legacy Python2 code that ends up with this type of error: (I assume that you have the python2-minimal package installed)
Python 2.7.18rc1 (default, Apr 7 2020, 12:05:55)
[GCC 9.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named requests
- best solution: port your code to Python3 :-) but the amount of effort can vary, and you are judge of how and when to do that
- solution I don't like: pip install the package: 99% of the solutions on the web mention this but IMHO it is not clean and can lead to issues, unless you use virtualenvs, pipenv, or docker etc.
- quick and easy solution: simply use the python3 package
If you read the readthedocs site for Request, http://python-requests.org/ ( = https://requests.readthedocs.io/en/master/), they say:
Requests officially supports Python 2.7 & 3.4–3.7, and runs great on PyPy.
=> it is enough to install on Ubuntu 20.04 the python3-requests
package (which is probably already present on your system),
then you can look at where the library has been installed:
$ dpkg -L python3-requests | grep __init__.py
/usr/lib/python3/dist-packages/requests/__init__.py
and either:
- create a sumbolic link from the python3 library zone to the python2 (probably
/usr/lib/python2.7/dist-packages
), or - add this line to your legacy code:
Python 2.7.18rc1 (default, Apr 7 2020, 12:05:55)
[GCC 9.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path.append('/usr/lib/python3/dist-packages')
>>> import requests
>>> ^D
Be aware however that simply doing this can be dangerous: some of the packages can be missing from the python2 library zone, taken from python3 and.. not be compatible! => you will have to check that your legacy application is working as intended.
Hope it helps.