I can’t run 'sudo apt install' on macOS even though Java is installed

43 views Asked by At

I am trying to install python3.11-dev on my Mac, but I cannot run any sudo apt-get or sudo apt commands.

When I type sudo apt-get install python3.11-dev in the terminal, I get the following error:

The operation couldn’t be completed. Unable to locate a Java Runtime that supports apt.
Please visit http://www.java.com for information on installing Java.

However, I do have Java installed. When I type java -version, I get this:

java version "22" 2024-03-19
Java(TM) SE Runtime Environment (build 22+36-2370)
Java HotSpot(TM) 64-Bit Server VM (build 22+36-2370, mixed mode, sharing)

I have Python 3.11 and 3.10 installed and they work fine. I run simple Python programs locally.

This issue stems from trying to compile a wrapper C file that has an include statement that reads #include <Python.h>. When I compile it with the path to my Python 3.11 included, I get the following error:

fatal error: 'Python.h' file not found
# include "Python.h"
          ^~~~~~~~~~
1 error generated.

I was told by peers who had the same issue that running sudo apt install on the python3.11 dev solves the issue, but I can't even run any sudo apt commands, so I am stuck.

Any ideas?

0

There are 0 answers