Open 1931540 opened 2 years ago
here's my conda env setting
name: minerl2
channels:
- conda-forge
- defaults
dependencies:
- python=3.8
- pip=22.1
- openjdk=8.0.312
- pip:
- git+https://github.com/minerllabs/minerl
Hey! Are you running on a headless machine without display? MineRL/Minecraft requires a valid display buffer to be able to run. You can use xvfb for this with xvfb-run -a python [your-code]
(on ubuntu installation is simple sudo apt install xvfb
).
I got the exact same error on my MacBook. Any update to this? I don't think xvfb-run
is available on MacOS.
Unfortunately MineRL v1.0 does not run on Mac at the moment, and no-one has had time to look into :(
OK, after hours of debug, I made it work on an MacBook Pro (with Apple Silicon M1 Pro) running MacOS 12.6.1. This solution SHOULD work on any Apple Silicon based Mac. Here is how I did it.
Download or clone the repository. This should create minerl
directory.
git clone https://github.com/minerllabs/minerl.git
Modify the patch file by replacing all 3.2.1
to 3.3.1
. This will update the version of lwjgl
to 3.3.1
.
Install the package using pip
. Inside minerl
directory, run the following command
pip install .
If installation failed, it could be the problem of JDK. The JDK I found working is the Oracle JDK 1.8, you will need to sign-in to download it. This JDK is for x86_64, so you will need Rosette to run it. Other people also has some success with OpenJDK.
If the previous step is successful, it should generate a directory called MCP-Reborn
. Modify the launchClient.sh
by adding -XstartOnFirstThread
in the line that runs java ......
(somewhere close to the bottom of the file), so the new line becomes.
java -Xmx$maxMem -XstartOnFirstThread -jar $fatjar --envPort=$port
Note: you can also change the memory for JVM by changing the 4G
defined in this file.
Modify the MCP-Reborn/src/main/java/net/minecraft/client/MainWindow.java
. Comment out or remove the line
GLFW.glfwSetWindowIcon(this.handle, buffer);
Also comment out or remove the entire method body of checkGlfwError
public static void checkGlfwError(BiConsumer<Integer, String> glfwErrorConsumer) {
// remove or comment out anything here
// DO NOT remove this method declaration
}
Rebuild MCP-Reborn. Inside MCP-Reborn
directory, run the following command
./gradlew clean build shadowJar
Overwrite the content inside MCP-Reborn
directory in the install location with the content of MCP-Reborn
we just modified. The exact install location depends on your python setup. It should be something like somepath/python3.x/site-packages/minerl/MCP-Reborn
.
Now you should be able to run the example provided in official documentation. DO NOT run python inside the minerl
directory we cloned, as it will mess up the python working directory.
lwjgl
starts to support Apple Silicon after version 3.3.0. The latest version at the time of writing is 3.3.1. See their release page for detail.-XstartOnFirstThread
JVM arguments is hinted by the error message. It just took some time for me to figure out where is java
called to start the minecraft instance.MainWindow.java
are necessary. It's appreciated if someone can verify this works. As I tried so many things in attempt to fix this, I might forgot to write everything down.
@lewisxy Oooo this is amazing! @trigaten any chance you could try this? I could also try on my M1 Mac but atm quite busy. It would be awesome to have this stuff merged into code :). It does not look like we are going to sacrifice any functionality. We just need to make sure these changes would still work on Windows and Linux.
I executed the command according to https://github.com/minerllabs/minerl/issues/659#issuecomment-1306635414 and confirmed that it works. Thanks @lewisxy! Environment M1 Mac + python 3.9 + poetry Commands
git clone https://github.com/minerllabs/minerl.git
sed -i .bak 's/3\.2\.1/3.3.1/' ./minerl/scripts/mcp_patch.diff
cd minerl && poetry run python setup.py
sed -i .bak s/'java -Xmx\$maxMem'/'java -Xmx\$maxMem -XstartOnFirstThread'/ ./minerl/MCP-Reborn/launchClient.sh
sed -i .bak /'GLFW.glfwSetWindowIcon(this.handle, buffer);'/d ./minerl/MCP-Reborn/src/main/java/net/minecraft/client/MainWindow.java
sed -i .bak '125,136s/^/\/\//' ./minerl/MCP-Reborn/src/main/java/net/minecraft/client/MainWindow.java
cd minerl/MCP-Reborn && ./gradlew clean build shadowJar
cd ../../../ && poetry add "git+https://github.com/minerllabs/minerl"
cp -rf minerrl/minerl/MCP-Reborn/* .venv/lib/python3.9/site-packages/minerl/MCP-Reborn/
This worked and I was able to install minerl on my m2 mac (woot). However, python is having trouble finding the minerl.data
module:
Traceback (most recent call last):
File "...", line 2, in <module>
import minerl.data
ModuleNotFoundError: No module named 'minerl.data'
Did you encounter this error at all?
I believe minerl.data
only works for older version (<=0.4.x
), and it is removed in newer version (>=1.0.x
).
Oh, I see. That'll do it. Thanks!
@Miffyli can confirm that @lewisxy solution above has also worked for me after the mixin 05.22.23 update. M1 Pro chip
@lewisxy Thank you so much for your helpful tutorial! I followed your steps but ended up getting this error: GLFW error 65548: Cocoa: Regular windows do not have icons on macOS. I was wondering if you have gotten an error like this before? I commented out the lines that you mentioned in MainWindow.java but I'm still getting the error. Do you have any ideas on how I could troubleshoot? Thank you so much!
above code has no error
but got error with env.reset()
I got the following error, and I cannot get minerl to work.