user11764216
user11764216

Reputation:

Can't install Python math library in Docker image

I am building a docker image. I have this command in Dockerfile -

pip3 install -r requirements.txt

The contents of the requirement.txt are -

Everything installs as it should other than "math". When Installing math following error message occurs -

ERROR: Could not find a version that satisfies the requirement math (from -r requirements.txt (line 7)) (from versions: none) ERROR: No matching distribution found for math (from -r requirements.txt (line 7))

How can I solve this and install math?

Upvotes: 4

Views: 4806

Answers (2)

Code-Apprentice
Code-Apprentice

Reputation: 83517

math is a built in library for python. You don't need to install it. Just remove it from requirements.txt.

If you are having a similar problem importing other Python modules in a Docker image using the requirements.txt file, make sure it is not one of Python's many, many other built-in functions. The complete list is here: https://docs.python.org/3.8/py-modindex.html

(Select the appropriate version from the dropdown menu at the top of the page.)

Upvotes: 7

K B
K B

Reputation: 23

math, along with Python's many, many other built-in modules, should not be included in the requirements.txt file. Delete that line from the file.

The complete list of built-in modules (i.e. modules which shouldn't be in requirements.txt) is here: https://docs.python.org/3.8/py-modindex.html

(Be sure to select your Python version from the dropdown menu at the top of the page.)

This post applies when creating a Docker image, such as with Binder from a GitHub repository. It does not apply when importing modules in a Python script.

Upvotes: 2

Related Questions