nsg-ethz / p4-utils

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

P4run is not using 2.7 by default #10

Closed BassamJaber closed 5 years ago

BassamJaber commented 5 years ago

After installing p4-utils, I tried to run the example using p4run. However, it seems that it is using python3 instead of python2 and the default is python 2.7.

Traceback (most recent call last):
  File "/usr/local/bin/p4run", line 11, in <module>
    load_entry_point('p4utils', 'console_scripts', 'p4run')()
  File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 487, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 2728, in load_entry_point
    return ep.load()
  File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 2346, in load
    return self.resolve()
  File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 2352, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "~/utils/p4utils/p4run.py", line 155
    print ' '.join(items)
            ^
SyntaxError: invalid syntax
python --version 
Python 2.7.12

How can I force p4run to use python2.7 instead of python3.5 ?

edgar-costa commented 5 years ago

weird, because the p4run script is explicitly using python2

https://github.com/nsg-ethz/p4-utils/blob/master/p4utils/p4run.py#L1

How do you call p4run? Whats your pip version?

BassamJaber commented 5 years ago

You are correct, pip is using python 3 instead. I managed to fix it by forcing python 2 for pip using python -m pip instead of just pip in install.sh script Thanks