I’m trying to run C3_W3_A1 assignement on my local mac jupyter notebook and getting the following error when executing this line of code env = gym.make(‘LunarLander-v2’) .
Error: box2D is not installed, run pip install gym[box2d]
When trying to install gym[box2d] I get a number of build errors linked to the installation of pygame dependencies.
These are the steps taken so far without much success:
Updated Xcode Command Line Tools using xcode-select --install.
Upgraded pip and setuptools to the latest versions.
Installed system dependencies (sdl2, sdl2_image, sdl2_ttf, sdl2_mixer) using Homebrew.
Attempted to install pygame separately using pip install --no-cache-dir pygame.
Retried installation of gym[box2d] using pip install --no-cache-dir "gym[box2d]".
× Building wheel for pygame (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [87 lines of output]
clang: warning: argument unused during compilation: ‘-L/usr/local/lib’ [-Wunused-command-line-argument]
In file included from src_c/imageext.c:29:
In file included from src_c/pygame.h:30:
In file included from src_c/_pygame.h:42:
In file included from /usr/local/include/SDL2/SDL.h:38:
In file included from /usr/local/include/SDL2/SDL_cpuinfo.h:111:
/Library/Developer/CommandLineTools/usr/lib/clang/14.0.0/include/immintrin.h:14:2: error: “This header is only meant to be used on x86 and x64 architecture” #error “This header is only meant to be used on x86 and x64 architecture”
^
In file included from src_c/imageext.c:29:
In file included from src_c/pygame.h:30:
In file included from src_c/_pygame.h:42:
In file included from /usr/local/include/SDL2/SDL.h:38:
In file included from /usr/local/include/SDL2/SDL_cpuinfo.h:111:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/14.0.0/include/immintrin.h:17:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/14.0.0/include/x86gprintrin.h:15:
/Library/Developer/CommandLineTools/usr/lib/clang/14.0.0/include/hresetintrin.h:42:27: error: invalid input constraint ‘a’ in asm asm (“hreset $0” :: “a”(__eax));
^
In file included from src_c/imageext.c:29:
In file included from src_c/pygame.h:30:
In file included from src_c/_pygame.h:42:
In file included from /usr/local/include/SDL2/SDL.h:38:
In file included from /usr/local/include/SDL2/SDL_cpuinfo.h:111:
In file included from /Library/Developer/CommandLineTools/usr/lib/clang/14.0.0/include/immintrin.h:21:
/Library/Developer/CommandLineTools/usr/lib/clang/14.0.0/include/mmintrin.h:14:2: error: “This header is only meant to be used on x86 and x64 architecture” #error “This header is only meant to be used on x86 and x64 architecture”
^
/Library/Developer/CommandLineTools/usr/lib/clang/14.0.0/include/mmintrin.h:54:12: error: invalid conversion between vector type ‘__m64’ (vector of 1 ‘long long’ value) and integer type ‘int’ of different size
return (__m64)__builtin_ia32_vec_init_v2si(__i, 0);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/usr/lib/clang/14.0.0/include/mmintrin.h:133:12: error: invalid conversion between vector type ‘__m64’ (vector of 1 ‘long long’ value) and integer type ‘int’ of different size
return (__m64)__builtin_ia32_packsswb((__v4hi)__m1, (__v4hi)__m2);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/usr/lib/clang/14.0.0/include/mmintrin.h:163:12: error: invalid conversion between vector type ‘__m64’ (vector of 1 ‘long long’ value) and integer type ‘int’ of different size
return (__m64)__builtin_ia32_packssdw((__v2si)__m1, (__v2si)__m2);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/usr/lib/clang/14.0.0/include/mmintrin.h:193:12: error: invalid conversion between vector type ‘__m64’ (vector of 1 ‘long long’ value) and integer type ‘int’ of different size
return (__m64)__builtin_ia32_packuswb((__v4hi)__m1, (__v4hi)__m2);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/usr/lib/clang/14.0.0/include/mmintrin.h:220:12: error: invalid conversion between vector type ‘__m64’ (vector of 1 ‘long long’ value) and integer type ‘int’ of different size
return (__m64)__builtin_ia32_punpckhbw((__v8qi)__m1, (__v8qi)__m2);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/usr/lib/clang/14.0.0/include/mmintrin.h:243:12: error: invalid conversion between vector type ‘__m64’ (vector of 1 ‘long long’ value) and integer type ‘int’ of different size
return (__m64)__builtin_ia32_punpckhwd((__v4hi)__m1, (__v4hi)__m2);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/usr/lib/clang/14.0.0/include/mmintrin.h:264:12: error: invalid conversion between vector type ‘__m64’ (vector of 1 ‘long long’ value) and integer type ‘int’ of different size
return (__m64)__builtin_ia32_punpckhdq((__v2si)__m1, (__v2si)__m2);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/usr/lib/clang/14.0.0/include/mmintrin.h:291:12: error: invalid conversion between vector type ‘__m64’ (vector of 1 ‘long long’ value) and integer type ‘int’ of different size
return (__m64)__builtin_ia32_punpcklbw((__v8qi)__m1, (__v8qi)__m2);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/usr/lib/clang/14.0.0/include/mmintrin.h:314:12: error: invalid conversion between vector type ‘__m64’ (vector of 1 ‘long long’ value) and integer type ‘int’ of different size
return (__m64)__builtin_ia32_punpcklwd((__v4hi)__m1, (__v4hi)__m2);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/usr/lib/clang/14.0.0/include/mmintrin.h:335:12: error: invalid conversion between vector type ‘__m64’ (vector of 1 ‘long long’ value) and integer type ‘int’ of different size
return (__m64)__builtin_ia32_punpckldq((__v2si)__m1, (__v2si)__m2);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/usr/lib/clang/14.0.0/include/mmintrin.h:356:12: error: invalid conversion between vector type ‘__m64’ (vector of 1 ‘long long’ value) and integer type ‘int’ of different size
return (__m64)__builtin_ia32_paddb((__v8qi)__m1, (__v8qi)__m2);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/usr/lib/clang/14.0.0/include/mmintrin.h:377:12: error: invalid conversion between vector type ‘__m64’ (vector of 1 ‘long long’ value) and integer type ‘int’ of different size
return (__m64)__builtin_ia32_paddw((__v4hi)__m1, (__v4hi)__m2);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/usr/lib/clang/14.0.0/include/mmintrin.h:398:12: error: invalid conversion between vector type ‘__m64’ (vector of 1 ‘long long’ value) and integer type ‘int’ of different size
return (__m64)__builtin_ia32_paddd((__v2si)__m1, (__v2si)__m2);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/usr/lib/clang/14.0.0/include/mmintrin.h:420:12: error: invalid conversion between vector type ‘__m64’ (vector of 1 ‘long long’ value) and integer type ‘int’ of different size
return (__m64)__builtin_ia32_paddsb((__v8qi)__m1, (__v8qi)__m2);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/usr/lib/clang/14.0.0/include/mmintrin.h:443:12: error: invalid conversion between vector type ‘__m64’ (vector of 1 ‘long long’ value) and integer type ‘int’ of different size
return (__m64)__builtin_ia32_paddsw((__v4hi)__m1, (__v4hi)__m2);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/usr/lib/clang/14.0.0/include/mmintrin.h:465:12: error: invalid conversion between vector type ‘__m64’ (vector of 1 ‘long long’ value) and integer type ‘int’ of different size
return (__m64)__builtin_ia32_paddusb((__v8qi)__m1, (__v8qi)__m2);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
---
For help with compilation see:
https://www.pygame.org/wiki/MacCompile
To contribute to pygame development see:
https://www.pygame.org/contribute.html
---
error: command '/usr/bin/clang' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for pygame
Building wheel for gym (pyproject.toml) … done
Created wheel for gym: filename=gym-0.26.2-py3-none-any.whl size=827618 sha256=215ec1465a5d0f217a5ccb6b10a38885e484ee8304aac5953c1c68de88842579
Stored in directory: /private/var/folders/mc/j32rprwn2qz132bngfg7nqpc0000gp/T/pip-ephem-wheel-cache-9zd1w6ld/wheels/95/51/6c/9bb05ebbe7c5cb8171dfaa3611f32622ca4658d53f31c79077
Successfully built box2d-py gym
Failed to build pygame
ERROR: Could not build wheels for pygame, which is required to install pyproject.toml-based projects
Although I really dont know if what Tom is stating is true, just in case if you still want to explore, I found two useful link which should help you resolve your issue.
The below GitHub mentions almost similar error as yours error, for which one of them has responded, try to go through all the comments.
@anlafuente, you can try updating your version to use gymnasium instead of gym. You’ll need to make some changes as @TMosh mentioned, since there are backward compatibility issues, but I think it won’t be too bad. I ran through the first few sections (through section 5), and found these were the only changes I needed to make after pip installing gymnasium:
import gymnasium as gym
there’s an extra info parameter returned by env.step() and env.reset(), so you need to add an extra underscore (_) for this extra return parameter that you can just ignore, like this:
There may be more that you’ll find if you do try this out and go through the whole project, but at first glance, it seems not too bad. You can google to get documentation on the gymnasium api if needed.
If you do try it, and find other things that need changing, please post it here. I’m going to let the course developers know that they may want to update assignment at some point to use gymnasium since gym is no longer supported, and I’ll update them with anything else you find to make their job easier when they get around to it. Other learners who are trying to run in their own environments may find it useful, too.