pythondocker-composepycharminterpreter

Getting "/usr/bin/which: no such file or directory" while setting up Python Interpreter from Docker Compose in PyCharm


I was trying to setup Python Interpreter for Django Project in PyCharm. I want to use the docker-compose image for python interpreter. So while configuring the interpreter, I selected the Docker Compose image. But it gave me an error.

Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "/usr/bin/which": stat /usr/bin/which: no such file or directory: unknown 
/usr/local/bin/docker-compose -f /project/path/docker-compose.yml -f /Users/<username>/Library/Caches/JetBrains/PyCharm2023.1/tmp/docker_compose/docker-compose.override.32.yml run --rm --no-deps <docker-image>

I tried installing which in the docker container as it was missing from usr/bin. But it didn't solve the problem. Still got the same error.


Solution

  • This seems to be an issue with PyCharm itself.

    It got resolved by disabling python.use.targets.api in Help -> Find Action -> Registry...

    https://youtrack.jetbrains.com/issue/PY-58702/Unable-to-create-docker-compose-based-interpreter-stat-usr-bin-which-no-such-file-or-directory-unknown#focus=Comments-27-6842697.0-0