0

I am editing the question because you did not understand the problem. And the problem still exists.

How do I install into a Docker container via pip3, modules that are not installed on the system. When I do that it says it is a managed environment, and does not proceed, BUT there is no debian package that installs that module. So how do I get the modules on there?

###############################################################

I will start off as I dabble in Python, but Python has all the things I need. I deploy my scripts in containers and run them from there.

So recently in a Dockerfile, based on debian:bookworm I get an error while installing modules using pip. All the articles say I have to install the modules via apt. Fine but some of the modules I need do not have a package. So I am screwed. They say I should use a venv, but I do not know how or what that is about and how it applies to a container.

My container is using the root user.

So how do I use venv inside a container so that entrypoint can use it?

Thanx

Bodger
  • 1,342
  • 4
  • 16
  • 23
  • You don't normally need a virtual environment in a container; the Python installation in the image is already isolated from other Pythons, and it's typical to install your application dependencies into the "system" Python. The linked question does go through approaches for doing it, though (along with at least one answer with a proper motivation for needing it). [What's the difference between Docker and Python virtualenv?](https://stackoverflow.com/questions/50974960/whats-the-difference-between-docker-and-python-virtualenv) may also be interesting to you. – David Maze Mar 24 '23 at 02:07
  • @DavidMaze Some images are perfectly safe to be used without virtual environment. Some are not. It's the same as without container. Typically every Python installation made from scratch is safe, because there are no pre-installed dependencies. Windows installations are safe to use without environment. Installed from source on Linux is safe. But Debian/Ubuntu are not safe because there are pre-installed dependencies that the OS itself depends on. So if your Docker container is based on a normal `ubuntu` image with `apt` installed Python then you better use a virtual environment. – sinoroc Mar 24 '23 at 11:11

0 Answers0