behavioral-model icon indicating copy to clipboard operation
behavioral-model copied to clipboard

No python modules for bmv2 and PI

Open Cheb-Zh opened this issue 2 years ago • 7 comments

Hi,

I installed the bmv2 and PI, but there are no python modules for them neither in site-packages nor dist-packages under /usr/lib/python3. But the CLIs for both work well. Could someone give some solutions? Thanks!

Cheb-Zh avatar Nov 29 '22 22:11 Cheb-Zh

If the CLI executables (installed on your system) work well, then the Python modules have been installed somewhere, and you just didn't find them. Location will vary based on distribution.

antoninbas avatar Nov 29 '22 22:11 antoninbas

If you have an Ubuntu 18.04, 20,04, or 22.04 system, freshly installed, then one of the install scripts mentioned on this page I test to work every month: https://github.com/jafingerhut/p4-guide/blob/master/bin/README-install-troubleshooting.md

There are also links on that page to VM images that can be loaded into VirtualBox (and maybe other similar VM software, but I have not tested others to verify) with already-compiled open source P4 software installed on them.

jfingerh avatar Nov 29 '22 23:11 jfingerh

I make no claims that there is any sane simple way to fix the system you have right now, and I have no interest in helping you figure out how to debug it. Sorry. It could take hours, or never work, and since I have a tested script that works starting from a freshly installed system, I recommend trying that out. It might save you time and frustration.

Andy

On Tue, Nov 29, 2022 at 6:49 PM Chengbo Zhou @.***> wrote:

Thanks for your answers. I have removed the modules from the site-packages to dist-packages. But when I import them, a ModuleNotFoundError: No module named 'p4.tmp' occurs. Since I used VSCode, the path of this module is linked to the PI/proto/py_out/p4. [image: image] https://user-images.githubusercontent.com/93914673/204673439-65f200e7-f295-4b29-b203-b41cc4ce3bb4.png

— Reply to this email directly, view it on GitHub https://github.com/p4lang/behavioral-model/issues/1163#issuecomment-1331465768, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAA2YPOQDJMVQYOLYBD7PC3WK2JCPANCNFSM6AAAAAASO7ZLEQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

jafingerhut avatar Nov 30 '22 00:11 jafingerhut

Really thanks for your answers!!! I have moved the modules to the dist-packages and given the read permission. Now the modules can be imported. But the other error shows up AttributeError: module 'google.protobuf.descriptor' has no attribute '_internal_create_key', when I import the p4config_pb2 from p4.tmp. I installed protobuf with version 3.18.1 which is mentioned in the PI repository.

Cheb-Zh avatar Nov 30 '22 00:11 Cheb-Zh

Got the solution from your hint. Thanks! The README of PI maybe should be updated. image

Cheb-Zh avatar Nov 30 '22 00:11 Cheb-Zh

You can struggle with this for as long as you enjoy it :-)

If you have a freshly installed Ubuntu 18.04, 20.04, or 22.04 system, my scripts will get you there much faster.

jfingerh avatar Nov 30 '22 14:11 jfingerh

Hahaha, I have already struggled with it for two months. Currently I want to communicate with the switch via P4runtime API. That's why several problems raised up. But everything works well right now. I believe there will be the other problems as long as I get deeper into that. :) BTW I was impressed how quickly you guys replied. Nice community here.

Cheb-Zh avatar Nov 30 '22 15:11 Cheb-Zh