简体   繁体   中英

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 -

  • pybind11
  • cppimport
  • jupyter
  • numpy
  • pandas
  • scikit-learn
  • math
  • random

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?

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 .)

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 (ie 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM