Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError: No module named 'p4.tmp' #463

Closed
nagmat1 opened this issue Apr 8, 2022 · 10 comments
Closed

ModuleNotFoundError: No module named 'p4.tmp' #463

nagmat1 opened this issue Apr 8, 2022 · 10 comments

Comments

@nagmat1
Copy link

nagmat1 commented Apr 8, 2022

I have installed the p4 and behavior model as mentioned on tutorial.
When I execute make build on basic folder. It executes normally :

mkdir -p build pcaps logs
p4c-bm2-ss --p4v 16 --p4runtime-files build/basic.p4.p4info.txt -o build/basic.json basic.p4

But when I am trying to run the program make run, I am getting this error :

mkdir -p build pcaps logs
p4c-bm2-ss --p4v 16 --p4runtime-files build/basic.p4.p4info.txt -o build/basic.json basic.p4
sudo python3 ../../utils/run_exercise.py -t pod-topo/topology.json -j build/basic.json -b simple_switch_grpc
Traceback (most recent call last):
  File "../../utils/run_exercise.py", line 28, in <module>
    import p4runtime_lib.simple_controller
  File "/home/nnazarov/deneme/p4c/build/tutorials/utils/p4runtime_lib/simple_controller.py", line 24, in <module>
    from . import bmv2, helper
  File "/home/nnazarov/deneme/p4c/build/tutorials/utils/p4runtime_lib/bmv2.py", line 15, in <module>
    from p4.tmp import p4config_pb2
ModuleNotFoundError: No module named 'p4.tmp'
make: *** [../../utils/Makefile:35: run] Error 1

What may be the problem?

@rst0git
Copy link
Member

rst0git commented Apr 9, 2022

@nagmat1 The p4.tmp module is provided by https://github.com/p4lang/PI

@jafingerhut
Copy link
Collaborator

You wrote "I have installed the p4 and behavior model as mentioned on tutorial."

Did you execute these commands to install it?

git clone https://github.com/p4lang/tutorials
cd tutorials/vm-ubuntu-20.04
vagrant up

If not, what commands did you use?

I test the commands above about once per month, and the last time I did, it did not have the problem you described.

@nagmat1
Copy link
Author

nagmat1 commented Apr 9, 2022

You wrote "I have installed the p4 and behavior model as mentioned on tutorial."

Did you execute these commands to install it?

git clone https://github.com/p4lang/tutorials
cd tutorials/vm-ubuntu-20.04
vagrant up

If not, what commands did you use?

I test the commands above about once per month, and the last time I did, it did not have the problem you described.

I am not using VM, I have installed on my PC.

@jafingerhut
Copy link
Collaborator

"I have installed on my PC." Do you mean a computer running some version of the Windows OS? That is probably one of the least tested platforms for running the open source P4 development tools. Ubuntu Linux is #1, some other Linux distros are #2, macOS is #3 and has some quirks, and I do not think Windows even makes the list, in terms of number of users.

I would recommend running a Linux VM on Windows, if you want to use a Windows system. That is much better supported in terms of things that have been well tested with P4 open source dev tools.

@nagmat1
Copy link
Author

nagmat1 commented Apr 9, 2022

No, the OS is Ubuntu 20.04,

I tried to install some other P4 code from other tutorial and both of them crashed I guess.

@jafingerhut
Copy link
Collaborator

jafingerhut commented Apr 9, 2022

So if you can give exactly which sequence of commands you used to try to install the P4 development tools, and ideally also save the output from those commands (since sometimes one can find where things went wrong by looking through such output), which OS you are using, etc., someone might be able to help you. But "hey, it did not work" is not nearly enough information to go on. (Yes, I know you gave a particular error message you are experiencing in the original issue, but if you want to know why it is giving that error, versus other ways of installing the P4 dev tools that do not give that error, more details are useful.)

@nagmat1
Copy link
Author

nagmat1 commented Apr 9, 2022

I resolved the issue.
I am using Ubuntu 20.04.
After executing make run, I was getting :

p4c-bm2-ss --p4v 16 --p4runtime-files build/basic.p4.p4info.txt -o build/basic.json basic.p4
sudo python3 ../../utils/run_exercise.py -t pod-topo/topology.json -j build/basic.json -b simple_switch_grpc
Traceback (most recent call last):
  File "../../utils/run_exercise.py", line 33, in <module>
    import p4runtime_lib.simple_controller
  File "/home/nnazarov/mysde/tutorials/utils/p4runtime_lib/simple_controller.py", line 22, in <module>
    from . import bmv2
  File "/home/nnazarov/mysde/tutorials/utils/p4runtime_lib/bmv2.py", line 15, in <module>
    from .switch import SwitchConnection
  File "/home/nnazarov/mysde/tutorials/utils/p4runtime_lib/switch.py", line 22, in <module>
    from p4.tmp import p4config_pb2
ModuleNotFoundError: No module named 'p4.tmp'
make: *** [../../utils/Makefile:35: run] Error 1

When I locate p4config_pb2 : I can see that :

usr/lib/python3/dist-packages/p4/tmp/p4config_pb2.py
/usr/lib/python3/dist-packages/p4/tmp/p4config_pb2_grpc.py
/usr/lib/python3/dist-packages/p4/tmp/__pycache__/p4config_pb2.cpython-38.pyc
/usr/lib/python3/dist-packages/p4/tmp/__pycache__/p4config_pb2_grpc.cpython-38.pyc
/usr/local/lib/python2.7/dist-packages/p4/tmp/p4config_pb2.py
/usr/local/lib/python2.7/dist-packages/p4/tmp/p4config_pb2.pyc
/usr/local/lib/python2.7/dist-packages/p4/tmp/p4config_pb2.pyo
/usr/local/lib/python2.7/dist-packages/p4/tmp/p4config_pb2_grpc.py
/usr/local/lib/python2.7/dist-packages/p4/tmp/p4config_pb2_grpc.pyc
/usr/local/lib/python2.7/dist-packages/p4/tmp/p4config_pb2_grpc.pyo

but somehow python was not getting the exact path.
Maybe not the best solution but I copied cp -r /usr/lib/python3/dist-packages/p4/ ~/mysde/tutorials/utils/ and it resolved the issue.

Thank you guys for taking your time and helping me resolve the issue.

@KekeZheng
Copy link

Oh! Thank you very much. I had the same problem and I solved it according to your solution!!

@PengZhan1998
Copy link

Oh! Thank you very much. I had the same problem and I solved it according to your solution!!!

@ruirui-wang-study
Copy link

I resolved the issue. I am using Ubuntu 20.04. After executing make run, I was getting :

p4c-bm2-ss --p4v 16 --p4runtime-files build/basic.p4.p4info.txt -o build/basic.json basic.p4
sudo python3 ../../utils/run_exercise.py -t pod-topo/topology.json -j build/basic.json -b simple_switch_grpc
Traceback (most recent call last):
  File "../../utils/run_exercise.py", line 33, in <module>
    import p4runtime_lib.simple_controller
  File "/home/nnazarov/mysde/tutorials/utils/p4runtime_lib/simple_controller.py", line 22, in <module>
    from . import bmv2
  File "/home/nnazarov/mysde/tutorials/utils/p4runtime_lib/bmv2.py", line 15, in <module>
    from .switch import SwitchConnection
  File "/home/nnazarov/mysde/tutorials/utils/p4runtime_lib/switch.py", line 22, in <module>
    from p4.tmp import p4config_pb2
ModuleNotFoundError: No module named 'p4.tmp'
make: *** [../../utils/Makefile:35: run] Error 1

When I locate p4config_pb2 : I can see that :

usr/lib/python3/dist-packages/p4/tmp/p4config_pb2.py
/usr/lib/python3/dist-packages/p4/tmp/p4config_pb2_grpc.py
/usr/lib/python3/dist-packages/p4/tmp/__pycache__/p4config_pb2.cpython-38.pyc
/usr/lib/python3/dist-packages/p4/tmp/__pycache__/p4config_pb2_grpc.cpython-38.pyc
/usr/local/lib/python2.7/dist-packages/p4/tmp/p4config_pb2.py
/usr/local/lib/python2.7/dist-packages/p4/tmp/p4config_pb2.pyc
/usr/local/lib/python2.7/dist-packages/p4/tmp/p4config_pb2.pyo
/usr/local/lib/python2.7/dist-packages/p4/tmp/p4config_pb2_grpc.py
/usr/local/lib/python2.7/dist-packages/p4/tmp/p4config_pb2_grpc.pyc
/usr/local/lib/python2.7/dist-packages/p4/tmp/p4config_pb2_grpc.pyo

but somehow python was not getting the exact path. Maybe not the best solution but I copied cp -r /usr/lib/python3/dist-packages/p4/ ~/mysde/tutorials/utils/ and it resolved the issue.

Thank you guys for taking your time and helping me resolve the issue.

I solve the same problem with your sulotion too!Thank you!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants