# ModuleNotFoundError: No module named 'p4' when running make run in exercises/basic

**URL:** <https://forum.p4.org/t/modulenotfounderror-no-module-named-p4-when-running-make-run-in-exercises-basic/1331>\
**Category:** Getting Started with P4\
**Created:** [June 6, 2025, 4:03pm UTC](https://forum.p4.org/t/modulenotfounderror-no-module-named-p4-when-running-make-run-in-exercises-basic/1331 "2025-06-06T16:03:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kacperkuczynski26](https://avatars.discourse-cdn.com/v4/letter/k/4da419/32.png) [@kacperkuczynski26](https://forum.p4.org/u/kacperkuczynski26)\
**Post date:** [June 6, 2025, 4:03pm UTC](https://forum.p4.org/t/modulenotfounderror-no-module-named-p4-when-running-make-run-in-exercises-basic/1331/1 "2025-06-06T16:03:39Z")

</div>

Hi all,

I’m working on the `basic` exercise from the official [p4lang/tutorials](https://github.com/p4lang/tutorials) repo on a clean installation of **Ubuntu 24.04 in VirtualBox**. I followed the setup steps including:

bash

```auto
git clone https://github.com/p4lang/tutorials
cd tutorials/vm-ubuntu-24.04
./install.sh

```

After that, I went to the `exercises/basic` folder and ran:

bash

```auto
make run

```

However, I get the following error:

```auto
Traceback (most recent call last):
  File "../../utils/run_exercise.py", line 29, in <module>
    import p4runtime_lib.simple_controller
  File "../../utils/p4runtime_lib/simple_controller.py", line 23, in <module>
    from p4.config.v1 import p4info_pb2
ModuleNotFoundError: No module named 'p4'

```

It seems like the generated `p4info_pb2.py` and `p4runtime_pb2.py` files are not structured properly for this import to work. What is the correct way to compile the `.proto` files so the Python imports work as expected?

Any help or clarification would be greatly appreciated!

Thanks in advance,  
Kacper

---

<div class="post-metadata">

**Author:** ![andyfingerhut](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.p4.org/andyfingerhut/32/17_2.png) [@andyfingerhut](https://forum.p4.org/u/andyfingerhut)\
**Post date:** [June 6, 2025, 4:11pm UTC](https://forum.p4.org/t/modulenotfounderror-no-module-named-p4-when-running-make-run-in-exercises-basic/1331/2 "2025-06-06T16:11:20Z")

</div>

When you ran `./install.sh`, if everything went successfully, it should have created a file named `p4setup.bash` in your home directory. It should also have appended the line `source ~/p4setup.bash` at the end of your ~/.bashrc file. Do you see those files, and that line in your ~/.bashrc file?

If so, then if you do anything that causes the ~/.bashrc file to be executed again, then it should add some directories to your command PATH, and do a couple of other useful things. Any of the following will cause the ~/.bashrc to be executed:

- log off, and log back on again. When you log back in, ~/.bashrc should be executed
- reboot your system. When you log in, ~/.bashrc should be executed
- Run the command `source ~/.bashrc`

One way to double-check whether the ~/p4setup.bash file has been executed is to show the value of a shell environment variable that it defines, as shown below:

```auto
$ echo $P4_EXTRA_SUDO_OPTS 
PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python

```

If the output is anything other than that, then the `p4setup.bash` script has not been executed, and you should figure out why.
