google / or-tools

Google's Operations Research tools:
https://developers.google.com/optimization/
Apache License 2.0
10.79k stars 2.09k forks source link

Installation in Docker on Mac M1 Processor #2516

Closed bechtold closed 3 years ago

bechtold commented 3 years ago

Hello, I'm getting an "ERROR: Could not find a version that satisfies the requirement ortools" all the time when trying to install ortools via pip inside a docker.

What version of OR-Tools and what language are you using? Version: latest Language: Python

What operating system (Linux, Windows, ...) and version? I tried different Linux images in docker desktop for mac on an m1 processor. Docker needs rosetta 2 to run. I tried the following images: FROM python:3-buster FROM python:3.9.2-buster FROM python:3.8-buster FROM ubuntu:18.04 FROM ubuntu:20.04

What did you do? Steps to reproduce the behavior: Start a docker container and run pip install ortools or pip install -r requirements.txt

What did you expect to see A working installation of ortools.

What did you see instead? ERROR: Could not find a version that satisfies the requirement ortools (from versions: none) ERROR: No matching distribution found for ortools

Anything else we should know about your project / environment I guess this has to do with the virtualization stuff. Docker Desktop needs to run in rosetta because it does not natively run on silicon chips. I'm not an expert on this, so it just took me three hours trying and resolve this bug and I had to give up. Switching to a Linux machine and installing ortools in docker there worked like a charm. Also, ortools run on a native installation on M1, that's why I initially didn't see tho problem with the M1. So I'm posting this mainly to let others know this problem currently exists, so they don't waste the same amount of time like I just did :-)

lperron commented 3 years ago

Duplicate

Mizux commented 3 years ago

to be precise duplicate of #2332

bechtold commented 3 years ago

Thx for the link, I was actually wondering why I didn't find it while searching for my issue.

I saw issue #2332, but that is about natively running or-tools on an M1 processor. It does run perfectly on my M1, it just doesn't run in a Docker on an M1. So I believe that my problem is different from #2332.

But I solved my problem by moving to another computer and creating my Dockerfile there. So I'm happy with leaving this issue closed.

zijian-wzj commented 2 years ago

Had the same issue as above when trying to install OR-tools in Docker on M1 Mac.

Managed to resolve it by building and running the image using the --platform linux/amd64 command. This will build and run the image with OR-tools using a linux/amd64 emulation instead of the default arm64 of M1 processor.

Dockerfile:

FROM python:latest
RUN pip install --upgrade pip
RUN pip install ortools

Docker commands:

docker build --platform linux/amd64 Dockerfile
docker run --platform linux/amd64 Image
lperron commented 2 years ago

I do not think the stack arm64 is properly supported in setuptools/pypi. Laurent Perron | Operations Research | @.*** | (33) 1 42 68 53 00

Le mer. 13 oct. 2021 à 08:09, zijian-wzj @.***> a écrit :

Had the same issue as above when trying to install OR-tools in Docker on M1 Mac.

Managed to resolve it by building and running the image using the --platform linux/amd64 command. This will build and run the image with OR-tools using a linux/amd64 emulation instead of the default arm64 of M1 processor.

Dockerfile:

FROM python:latest RUN pip install --upgrade pip RUN pip install ortools

Docker commands:

docker build --platform linux/amd64 Dockerfile docker run --platform linux/amd64 Image

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/google/or-tools/issues/2516#issuecomment-941953865, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUPL3NI4UUHEYMCJCLPO7DUGUPBVANCNFSM43IUE6TA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.