ModuleNotFoundError: No module named 'raylib._raylib_cffi'
This means that you have the raylib module python files installed, but you do not have the native binary DLL installed.
There are two ways you can get it:
-
When you install with pip, it should search pypi for a binary wheel that contains both the python files and an appropriate DLL for your system. All of the binary wheels are listed here and can be downloaded manually: https://pypi.org/project/raylib/#files . If there is a wheel for your system but pip is failing to find it automatically this is a bug so please let us know. (If there if there is no wheel you could request we add one, but we can't cover every possible platform.)
-
If there is no wheel, then pip will attempt to compile one from the source code. This has apparently failed. Run
pip -vvv install rayliband see if you can spot an error. If there is no error then this itself is a bug so report it. For more info on compiling see https://github.com/electronstudio/raylib-python-cffi/blob/master/BUILDING.rst
Potential New Bug Report
Environment:
-
OS: Microsoft Windows 11 Pro (24H2)
-
IDE: PyCharm 2024.1.1 (Professional Edition)
-
Python: 3.12.2 (Anaconda, MSC v.1916 64-bit)
-
Installation:
-
Installed
raylibvia Quickstart Guide -
Downloaded and installed
raylib binariesfrom official site
-
-
Virtual Environment: Created using
python -m venv venv
Issue:
When running the official example code in PyCharm (via right-click → Run or navbar Run button), it throws:
ModuleNotFoundError: No module named 'raylib._raylib_cffi' (Issue #142).
Critical Observation: The same script runs successfully when executed directly in the terminal. This inconsistency prevents debugging within PyCharm.
Reproduction Steps:
-
Create virtual environment:
python -m venv venv -
Install
raylibas per documentation -
Run example code in PyCharm → Error occurs
-
Run identical code in terminal → Executes normally
Request: Help diagnose why PyCharm fails to resolve the module despite correct terminal execution.
That’s very strange. If they are both running the same venv I would expect them to run the same, either both work or both fail. Somehow Pycharm is using a raylib module that doesn’t have the required DLL while Powershell is using one that does.
I would guess it’s related to using Python from Anaconda. We only test and provide binaries for Python.org Python, so I suggest you use that.