Java repl has messed up Python environment

Question: Why can’t I install Python packages in a Java repl?

I understand that it’s a Java repl, not a Python one. However, it would still be really useful to be able to install some Python packages.

Specifically, I am trying to find a getch alternative, because the getch that I normally use doesn’t seem to work in Replit.

Repl link:

Here’s some things I tried:

python3 -m pip install ... # No module named pip
python3 -m ensurepip --user # success
python3 -m pip install ... # No module named pip... wait, what?
pip # worked, showed help message for pip.
pip install ... # Can not execute `` since setuptools is not available in the build environment.
pip install setuptools --user # success
pip install ... # Same error as before.

Hi @sillypantscoder you wouldn’t be able to use the Python package from Java.

I’m assuming you want to use getch (the Python package) to capture keypresses? If so have you investigated using Java keylistener events instead?

I wrote my own getch in Python, not knowing about the builtin package.
The keylistener events look like they work on a window, not in the terminal.
I just started rewriting my program in Java:

class Getch {
	public static void main(String[] args) {
		// Example:
		String g = getch();
		// this is a working solution!
		// this does not require the enter key to be pressed!
		// The only thing is that the arrow keys return "A", "B", "C", and "D"
		// instead of a unique value
	public static void stopBuffering() {
		try {
			ProcessBuilder pb = new ProcessBuilder("stty", "-icanon", "min", "1");
		} catch(IOException e) {
		} catch(InterruptedException e) {
	public static String getch() {
		try {
			// Read a byte
			byte[] i = new byte[4];;
			byte[] retBytes = new byte[] {
			// Check if byte is escape code
			if (i[0] == 27) {
				retBytes = new byte[] {
			String str = new String(retBytes, StandardCharsets.UTF_8);
			return str;
		} catch(IOException e) {
			return "";

Ok. Best of luck with this! I know from some research that it’s a common question online and I’ve not yet found a solution that doesn’t require the ENTER key to be pressed at some point.

There will be a lot of happy programmers out there if you can solve this!