Install raylib - error

Sorry, forgot to add that I still get the same error, which is

myusername@pureos:~$ python3 game.py
Traceback (most recent call last):
File “/home/myusername/Desktop/game.py”, line 2, in
from raylib import *
File “/usr/local/lib/python3.9/dist-packages/raylib/init.py”, line 15, in
from ._raylib_cffi import ffi, lib as rl
ModuleNotFoundError: No module named ‘raylib._raylib_cffi’

Does the game if you run it with sudo?

sadly not.

After asking pip show raylib please use (I tested this):

This should end up on Librem 5 with the successful installation of raylib-2.6.0. Afterwards please run your related game.py and let us know if at least this older version of installed raylib package serves the purpose?

pip raylib outputs

username@pureos:~$ pip show raylib
Name: raylib
Version: 4.0.0.6
Summary: Python CFFI bindings for Raylib
Home-page: https://github.com/electronstudio/raylib-python-cffi
Author: Electron Studio
Author-email: github@electronstudio.co.uk
License: EPL-2.0
Location: /usr/local/lib/python3.9/dist-packages
Requires: cffi, inflection
Required-by:

pip3 install --no-binary raylib --upgrade --force-reinstall raylib outputs

username@pureos:~$ pip3 install --no-binary raylib --upgrade --force-reinstall raylib
Defaulting to user installation because normal site-packages is not writeable
Collecting raylib
Using cached raylib-4.0.0.6.tar.gz (61 kB)
Preparing metadata (setup.py) … error
error: subprocess-exited-with-error

× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [29 lines of output]
Traceback (most recent call last):
File “”, line 2, in
File “”, line 34, in
File “/tmp/pip-install-s5dclfd5/raylib_1864f47e81664cfeab8b3f1317219ae9/setup.py”, line 20, in
setup(
File “/home/username/.local/lib/python3.9/site-packages/setuptools/init.py”, line 87, in setup
return distutils.core.setup(**attrs)
File “/home/username/.local/lib/python3.9/site-packages/setuptools/_distutils/core.py”, line 109, in setup
_setup_distribution = dist = klass(attrs)
File “/home/username/.local/lib/python3.9/site-packages/setuptools/dist.py”, line 462, in init
_Distribution.init(
File “/home/username/.local/lib/python3.9/site-packages/setuptools/_distutils/dist.py”, line 293, in init
self.finalize_options()
File “/home/username/.local/lib/python3.9/site-packages/setuptools/dist.py”, line 886, in finalize_options
ep(self)
File “/home/username/.local/lib/python3.9/site-packages/setuptools/dist.py”, line 907, in _finalize_setup_keywords
ep.load()(self, ep.name, value)
File “/home/username/.local/lib/python3.9/site-packages/cffi/setuptools_ext.py”, line 219, in cffi_modules
add_cffi_module(dist, cffi_module)
File “/home/username/.local/lib/python3.9/site-packages/cffi/setuptools_ext.py”, line 49, in add_cffi_module
execfile(build_file_name, mod_vars)
File “/home/username/.local/lib/python3.9/site-packages/cffi/setuptools_ext.py”, line 25, in execfile
exec(code, glob, glob)
File “raylib/build.py”, line 189, in
build_unix()
File “raylib/build.py”, line 101, in build_unix
raise Exception(“ERROR: raylib not found by pkg-config. Please install pkg-config and Raylib.”)
Exception: ERROR: raylib not found by pkg-config. Please install pkg-config and Raylib.
not windows, trying Unix build
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

trying to run the game then, outputs

myusername@pureos:~$ python3 game.py
Traceback (most recent call last):
File “/home/myusername/Desktop/game.py”, line 2, in
from raylib import *
File “/usr/local/lib/python3.9/dist-packages/raylib/init.py”, line 15, in
from ._raylib_cffi import ffi, lib as rl
ModuleNotFoundError: No module named ‘raylib._raylib_cffi’

1 Like

This post is more about direction (draft) on how to and less about solution (perhaps). At the same it is based on the fact that I wasn’t sure (relatively) on why we are getting to this destination:

And I forgot to add sudo -H up front of the related command (please correct me any time when I’m lost), which is also irrelevant from now on and here:

Kind of self-explanation of above is here:
sudo apt install mesa-utils
glxinfo | grep "Mesa" −− will show us OpenGL version of 2.1.

But anyway and although I wasn’t getting such error output(s) we will rather follow this guide: https://github.com/raysan5/raylib/wiki/Working-on-GNU-Linux and install packages that might be currently missing on Librem 5, while purposely related:
sudo apt update
sudo apt full-upgrade
sudo apt autoremove
sudo apt install aptitude −− while my PureOS installation needed so.
sudo aptitude install g++ −− for C++. Accept …? First answer is no, second one is Yes.
NOTE: install gcc (instead of g++) if you are going to use C (see link to the related video below).

Those packages below we will need to install soon (please continue reading):

apt list libasound2-dev mesa-common-dev libx11-dev libxrandr-dev libxi-dev libglu1-mesa-dev libgles2-mesa-dev libgbm-dev
sudo apt install libasound2-dev mesa-common-dev libx11-dev libxrandr-dev libxi-dev libglu1-mesa-dev libgles2-mesa-dev libgbm-dev
apt list libgl1-mesa-dev libwayland-dev libxkbcommon-dev libglfw3-wayland wayland-protocols
sudo apt install libgl1-mesa-dev libwayland-dev libxkbcommon-dev libglfw3-wayland wayland-protocols

sudo apt update
apt list xorg-dev −− probably installed already.

Before we start to implement above PureOS packages:
python3 -m pip uninstall raylib −− would be needed if raylib-2.6.0 successfully installed - but it wasn’t.
sudo python3 -m pip uninstall raylib
pip3 show raylib −− should not be found.
mkdir myraylib
cd myraylib

git clone https://github.com/raysan5/raylib.git raylib
−− please use WiFi connection= 368.43MiB download+.

Let us now install above selected packages with sudo apt ... and afterwards continue from here:
cd raylib
mkdir build && cd build
apt list cmake

sudo -H cmake -DSHARED=ON -DSTATIC=ON ..
sudo -H make PLATFORM=PLATFORM_DRM
sudo -H make PLATFORM=PLATFORM_DESKTOP RAYLIB_LIBTYPE=SHARED GRAPHICS=GRAPHICS_API_OPENGL_21 -B
sudo -H make install RAYLIB_LIBTYPE=SHARED

cd ..
cd examples

sudo -H make core/core_basic_window PLATFORM=PLATFORM_DRM -B
sudo -H make core/core_basic_window PLATFORM=PLATFORM_DESKTOP RAYLIB_LIBTYPE=SHARED GRAPHICS=GRAPHICS_API_OPENGL_21 -B

cd core
./core_basic_window


Hope that this post here helps (as have few other things to do on my list today)! Also and only if commands under ~/myraylib/raylib/build did not help (not sure any more) you should switch to ~/myraylib/raylib/src and repeat (as I’m requesting your feedback kindly):

sudo -H make PLATFORM=PLATFORM_DRM
sudo -H make PLATFORM=PLATFORM_DESKTOP RAYLIB_LIBTYPE=SHARED GRAPHICS=GRAPHICS_API_OPENGL_21 -B
sudo -H make install RAYLIB_LIBTYPE=SHARED

Inspiration for this post and some sources:

https://github.com/raysan5/raylib/wiki/Working-on-Raspberry-Pi#user-content-compiling-raylib-source-code
https://github.com/raysan5/raylib/issues/706
https://www.youtube.com/watch?v=R0jsXG4xahM
https://mesamatrix.net/

In addition I executed (but probably not relevant):
sudo apt purge python2.7-minimal

1 Like

first off, thanks for the big effort you have done, which shows me how much you care about me being helped.

I had 4 obstacles.

obstacle 1 - wayland-protocols-devel doesnt exist in PureOS packages even when listing for it worked

obstacle 2 - I had to install cmake first before doing any cmake-related stuff

obstacle 3 - sudo -H cmake -DSHARED=ON -DSTATIC=ON .. resulted in

Cmake Error at src/external/glfw/CMakeLists.txt:168 (message):
xinerama headers not found; install libxinerama development package

– Configuring incomplete, errors occured! See also “/home/username/myraylib/raylib/build/CMakeFiles/CMakeOutput.log”.
See also “/home/username/myraylib/raylib/build/CMakeFiles/CMakeError.log”

after receiving that error, I listed libxinerama but it couldn’t locate the package when trying to install it.
So I switched directory to /src

obstacle 4 - sudo -H make PLATFORM=PLATFORM_DESKTOP RAYLIB_LIBTYPE=SHARED GRAPHICS=GRAPHICS_API_OPENGL_21 -B resulted in


the next command being sudo -H make install RAYLIB_LIBTYPE=SHARED resulted in error ofc, which was

cp: cannot stat ‘…/src/libraylib.so.4.0.0’: No such file or directory
make: *** [Makefile:716: install] Error 1

after changing directory to examples I ran sudo -H make core/core_basic_window PLATFORM=PLATFORM_DRM -B, which resulted in


the rest, I didn’t follow anymore as it wouldn’t have made any sense at that point.

1 Like

wayland-protocols is correct name for package to be installed (I’m about to edit my post).

apt list *libxinerama*
sudo apt install libxinerama-dev libxinerama1 −− the missing ones (I had those already installed).

Please execute before anything else:

Furthermore please check and install if not installed (or gcc instead of g++ if you are going to use C) those two packages:
apt list g++ build-essential
sudo apt install g++
sudo apt install build-essential −− very basic package to be installed for everything related to raylib, my fault not to mention what described within linked official instruction from developer (and as I had it installed much earlier on my Linux phone).

Optionally:
sudo aptitude install g++ −− as explained in my post above.

1 Like

once I ran sudo -H cmake -DSHARED=ON -DSTATIC=ON .. that resulted in same error as before, I changed directory to /src.

Once again ran first command there and then sudo -H make PLATFORM=PLATFORM_DESKTOP RAYLIB_LIBTYPE=SHARED GRAPHICS=GRAPHICS_API_OPENGL_21 -B which gave me the same error as it did in my previous attempt which is “screenshot 1”.

I indeed needed to adapt and be focused on several other “things” (other than need to install build-essential package) as otherwise linked guide would be useless on Librem 5, as just partially written because: “Actually, my intention is removing old OpenGL versions in the future…”.

@wednesday, I would like to know which package you are using:
apt list g++ or
apt list gcc −− as your above post shows

Options are that you create new L5raylib directory (and afterwards remove old one completely), and after all needed packages available to build … (there is none to be skipped) start with git clone .... Go straight to /src directory … should work as long as all needed packages arm64 [installed] (repeat apt list … for all of them. Otherwise we “see” us tomorrow.

apt list python2.7-minimal
apt list python3.9 −− should be installed

xorg-dev package needs to be installed (if not already).

EDIT: Thought about raylib-dependencies just came back to my mind:
https://github.com/raysan5/raylib/wiki/raylib-dependencies −− refers to
https://github.com/raysan5/raylib/tree/master/src/external −− refers to
https://github.com/raysan5/raylib/tree/master/src/external/glfw −− apt list libglfw3-wayland, etc.

At this moment not sure how to help you further (with one step), but anyway above main link will lead us to solution :wink:, we will get there on your Librem 5 (your findings are important inputs toward solution).

Please take a look if below packages installed:
python3 -m pip freeze --local
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade cffi glad inflection pycparser

I ran into the same error as before.