ModuleNotFoundError: No module named 'pybullet' even after installing PyBullet

1.1k views Asked by At

I have installed pybullet with

!pip install pybullet

It shows a warning:

WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead

But otherwise installed successfully.

However when in later code when I try to import it as

import pybullet as p

It shows the following error:

ModuleNotFoundError: No module named 'pybullet'

How do I fix it?

1

There are 1 answers

0
inept_python On

How are you running the code? The warning pip gave you when you ran pip as root may well be relevant. If you install a library as root with pip, i.e.

sudo pip install numpy

Then you may not have access to that library in a Python program you write, unless you run it as root as well.

python simple-numpy-program.py # probably fails
sudo python simple-numpy-program.py # probably runs

This being said, pip is correct, you generally should not run it as root. Why don't you just make a new virtual environment for your project, and install pybullet there?

python -m venv env
source env/bin/activate
pip install pybullet