nsg-ethz / p4-utils

Extension to Mininet that makes P4 networks easier to build
GNU General Public License v2.0
188 stars 68 forks source link

protobuf requires Python '>=3.7' but the running Python is 3.6.9 #36

Closed Benature closed 1 year ago

Benature commented 2 years ago

I want to install p4-utils in my own ubuntu18.04, but

user@v:~/p4-tools/p4-utils$ sudo ./install.sh
The directory '/home/user/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/user/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Obtaining file:///home/user/p4-tools/p4-utils
Collecting googleapis-common-protos>=1.52 (from p4utils==0.2)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/4f/35/ebcc4d2ca9cf895547576e17b8c41172d19473b0c4b24f6f6c273849e00b/googleapis_common_protos-1.56.2-py2.py3-none-any.whl (211kB)
    100% |████████████████████████████████| 215kB 3.5MB/s 
Collecting grpcio>=1.17.2 (from p4utils==0.2)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/61/dd/d8eda79197a1275e06621850775c7bbf34a141ff92553754dde4e87d7551/grpcio-1.46.3.tar.gz (21.8MB)
    100% |████████████████████████████████| 21.9MB 70kB/s 
Requirement already satisfied: ipaddr in /usr/local/lib/python3.6/dist-packages (from p4utils==0.2)
Requirement already satisfied: ipaddress in /usr/local/lib/python3.6/dist-packages (from p4utils==0.2)
Requirement already satisfied: networkx in /home/user/.local/lib/python3.6/site-packages (from p4utils==0.2)
Collecting p4runtime (from p4utils==0.2)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/d7/78/7823db0b5716c6040733e537ed8afe4d821b66928c0746d5e7098fcfe388/p4runtime-1.3.0-0-py3-none-any.whl
Collecting protobuf>=3.6.1 (from p4utils==0.2)
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/6c/be/4e32d02bf08b8f76bf6e59f2a531690c1e4264530404501f3489ca975d9a/protobuf-4.21.0-py2.py3-none-any.whl (164kB)
    100% |████████████████████████████████| 174kB 1.9MB/s 
protobuf requires Python '>=3.7' but the running Python is 3.6.9
user@v:~/p4-tools/p4-utils$ python -V
Python 3.6.9
user@v:~/p4-tools/p4-utils$ pip -V
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)

The p4-utils folder is copied from provided VM, the git log is commit 3e5a3600736831ec717f4637a4eb75c3b3b19755.

p4@ict-networks-010-000-002-015:~/p4-tools/p4-utils$ sudo ./install.sh
The directory '/home/p4/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/p4/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Obtaining file:///home/p4/p4-tools/p4-utils
Requirement already satisfied: googleapis-common-protos>=1.52 in /usr/local/lib/python3.6/dist-packages (from p4utils==0.2)
Requirement already satisfied: grpcio>=1.17.2 in /usr/local/lib/python3.6/dist-packages (from p4utils==0.2)
Requirement already satisfied: ipaddr in /usr/local/lib/python3.6/dist-packages (from p4utils==0.2)
Requirement already satisfied: ipaddress in /usr/local/lib/python3.6/dist-packages (from p4utils==0.2)
Requirement already satisfied: networkx in /usr/local/lib/python3.6/dist-packages (from p4utils==0.2)
Requirement already satisfied: p4runtime in /usr/local/lib/python3.6/dist-packages (from p4utils==0.2)
Requirement already satisfied: protobuf>=3.6.1 in /usr/local/lib/python3.6/dist-packages (from p4utils==0.2)
Requirement already satisfied: psutil in /usr/local/lib/python3.6/dist-packages (from p4utils==0.2)
Requirement already satisfied: scapy==2.4.4 in /usr/local/lib/python3.6/dist-packages (from p4utils==0.2)
Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (from p4utils==0.2)
Requirement already satisfied: six>=1.5.2 in /usr/local/lib/python3.6/dist-packages/six-1.16.0-py3.6.egg (from grpcio>=1.17.2->p4utils==0.2)
Requirement already satisfied: decorator<5,>=4.3 in /usr/local/lib/python3.6/dist-packages (from networkx->p4utils==0.2)
Installing collected packages: p4utils
  Found existing installation: p4utils 0.2
    Can't uninstall 'p4utils'. No files were found to uninstall.
  Running setup.py develop for p4utils
Successfully installed p4utils
p4@ict-networks-010-000-002-015:~/p4-tools/p4-utils$ pip -V
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)
p4@ict-networks-010-000-002-015:~/p4-tools/p4-utils$ python -V
Python 3.6.9

I tried in VM but it success, the python version and pip version is the same. I wonder how the protobuf is installed in VM?

Benature commented 2 years ago

I've tried python3.8 and pip3.8, but encountered another error (with a very long log)

edgar-costa commented 2 years ago

Hi

Protobuffer is installed here: https://github.com/nsg-ethz/p4-utils/blob/master/install-tools/install-p4-dev.sh#L228 for our version of bmv2 and p4c, protobuf v3.6 was the recommended one, see here https://github.com/nsg-ethz/p4-utils/blob/master/install-tools/install-p4-dev.sh#L20.

AmazingBJ commented 2 years ago

I've tried python3.8 and pip3.8, but encountered another error (with a very long log)

Hi,did you solve this?

Benature commented 2 years ago

Hi, @edgar-costa I did run the install-p4-dev.sh, only then did I install p4-utils.

I think the error is raised because setup.py requires 'protobuf >= 3.6.1'. Or to make sure I finish running install-p4-dev.sh successfully, how can I check the installed protobuf version?

AmazingBJ commented 2 years ago

you can run "protoc --version"

Benature commented 2 years ago

you can run "protoc --version"

@AmazingBJ Thank you.

user@v:~/p4-tools/protobuf$ protoc --version
libprotoc 3.6.1

So the protobuf is indeed installed with version 3.6.1, which is the same as https://github.com/nsg-ethz/p4-utils/blob/master/install-tools/install-p4-dev.sh#L20.

AmazingBJ commented 2 years ago

but i install p4-utils,still report protobuf requires Python '>=3.7' but the running Python is 3.6.9,how can i fix this.if i did not install p4-utils correctly,when i run "sudo p4run" in /p4-learning/exer...,it will report no such command

Benature commented 2 years ago

but i install p4-utils,still report protobuf requires Python '>=3.7' but the running Python is 3.6.9,how can i fix this.if i did not install p4-utils correctly,when i run "sudo p4run" in /p4-learning/exer...,it will report no such command

same

AmazingBJ commented 2 years ago

but i install p4-utils,still report protobuf requires Python '>=3.7' but the running Python is 3.6.9,how can i fix this.if i did not install p4-utils correctly,when i run "sudo p4run" in /p4-learning/exer...,it will report no such command

I success install when I checkout branch to simple-frr.I hope it will help you.

Benature commented 2 years ago

@AmazingBJ Thank you, in brach simple-frr, I can successfully install p4-utils, and p4run is fine

user@v:~/p4-tools/p4-utils$ p4run -h
usage: p4run [-h] [--config CONFIG] [--log-dir LOG_DIR] [--pcap-dir] [--cli]
             [--verbosity] [--clean] [--clean-dir] [--empty-p4]

optional arguments:
  -h, --help         show this help message and exit
  --config CONFIG    Path to configuration
  --log-dir LOG_DIR
  --pcap-dir         Generate pcap files for interfaces.
  --cli              Run mininet CLI.
  --verbosity        Set messages verbosity.
  --clean            Cleans previous log files
  --clean-dir        Cleans previous log files and closes
  --empty-p4         Runs the topology with an empty p4 program that does
                     nothing

But I'm afraid the version is a bit too old, it required old version's field in p4app.json when I run p4run

Traceback (most recent call last):
  File "/usr/local/bin/p4run", line 11, in <module>
    load_entry_point('p4utils', 'console_scripts', 'p4run')()
  File "/home/user/p4-tools/p4-utils/p4utils/p4run.py", line 855, in main
    verbosity=args.verbosity)                  
  File "/home/user/p4-tools/p4-utils/p4utils/p4run.py", line 317, in __init__
    self.switches = self.parse_switches(topology.get('switches', None))
  File "/home/user/p4-tools/p4-utils/p4utils/p4run.py", line 368, in parse_switches
    'p4_src': self.conf['p4_src'],
KeyError: 'p4_src'
AmazingBJ commented 2 years ago

@AmazingBJ Thank you, in brach simple-frr, I can successfully install p4-utils, and p4run is fine

user@v:~/p4-tools/p4-utils$ p4run -h
usage: p4run [-h] [--config CONFIG] [--log-dir LOG_DIR] [--pcap-dir] [--cli]
             [--verbosity] [--clean] [--clean-dir] [--empty-p4]

optional arguments:
  -h, --help         show this help message and exit
  --config CONFIG    Path to configuration
  --log-dir LOG_DIR
  --pcap-dir         Generate pcap files for interfaces.
  --cli              Run mininet CLI.
  --verbosity        Set messages verbosity.
  --clean            Cleans previous log files
  --clean-dir        Cleans previous log files and closes
  --empty-p4         Runs the topology with an empty p4 program that does
                     nothing

But I'm afraid the version is a bit too old, it required old version's field in p4app.json when I run p4run

Traceback (most recent call last):
  File "/usr/local/bin/p4run", line 11, in <module>
    load_entry_point('p4utils', 'console_scripts', 'p4run')()
  File "/home/user/p4-tools/p4-utils/p4utils/p4run.py", line 855, in main
    verbosity=args.verbosity)                  
  File "/home/user/p4-tools/p4-utils/p4utils/p4run.py", line 317, in __init__
    self.switches = self.parse_switches(topology.get('switches', None))
  File "/home/user/p4-tools/p4-utils/p4utils/p4run.py", line 368, in parse_switches
    'p4_src': self.conf['p4_src'],
KeyError: 'p4_src'

sry,I have no idea about this.Perhaps you can checkout other branch.

Benature commented 2 years ago

@AmazingBJ Oh sorry, p4_src is not an old field, please ignore my last comment. I will do more test later in the simple-frr branch later.

AmazingBJ commented 2 years ago

@AmazingBJ Oh sorry, p4_src is not an old field, please ignore my last comment. I will do more test later in the simple-frr branch later.

okay

Benature commented 2 years ago

@edgar-costa Hi, with branch simple-frr, the log file is empty, though config turn it on

"enable_log": true,
Vic0428 commented 2 years ago

It seems one workaround is to constrain the protobuf version as https://github.com/protocolbuffers/protobuf/issues/10053 suggests.

You can modify setup.py in this way (https://github.com/nsg-ethz/p4-utils/compare/master...Vic0428:p4-utils:master)!

YXY-1998 commented 2 years ago

似乎一种解决方法是像protobuers/protobuf#10053所建议的那样限制protobuf版本。

您可以以这种方式进行修改(主...Vic0428:p4-utils:master)!setup.py

Hello, I tried this method and I can successfully install p4utils, but when I execute the command p4run, it still cannot be successfully executed, do you know how to solve it? When executing p4run, the display is as follows:

Traceback (most recent call last): File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 574, in _build_master ws.require(requires) File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 892, in require needed = self.resolve(parse_requirements(requirements)) File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 783, in resolve raise VersionConflict(dist, req).with_context(dependent_req) pkg_resources.ContextualVersionConflict: (protobuf 3.6.1 (/usr/local/lib/python3.6/dist-packages), Requirement.parse('protobuf<5.0.0dev,>=3.15.0'), {'googleapis-common-protos'})

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/bin/p4run", line 6, in from pkg_resources import load_entry_point File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 3088, in @_call_aside File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 3072, in _call_aside f(*args, **kwargs) File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 3101, in _initialize_master_working_set working_set = WorkingSet._build_master() File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 576, in _build_master return cls._build_from_requirements(requires) File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 589, in _build_from_requirements dists = ws.resolve(reqs, Environment()) File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 783, in resolve raise VersionConflict(dist, req).with_context(dependent_req) pkg_resources.ContextualVersionConflict: (protobuf 3.6.1 (/usr/local/lib/python3.6/dist-packages), Requirement.parse('protobuf<5.0.0dev,>=3.15.0'), {'googleapis-common-protos'})