michele-segata / plexe-pyapi

Python APIs to control Plexe models in SUMO
49 stars 14 forks source link

Minor update for running examples, this will work with python3.x not … #4

Closed SafrasIqbal closed 4 years ago

SafrasIqbal commented 4 years ago

…python2.x

Hi Micheal,

I followed the instructions and try to execute the example with the commands provided. However, I faced issues with imports as below.

''' safras@Safrass-MacBook-Pro examples % python joindemo.py Traceback (most recent call last): File "joindemo.py", line 22, in from utils import add_platooning_vehicle, communicate, get_distance, \ File "/Users/safras/src/plexe-pyapi/examples/utils.py", line 30, in from plexe import POS_X, POS_Y, ENGINE_MODEL_REALISTIC #test chnage path ImportError: No module named plexe ''' there were some sources on how to fix this issue, I started changing the code but it seems never-ending.... then I realised this is due to python version mismatch.

my version for python as below.

''' safras@Safrass-MacBook-Pro examples % python -V
Python 2.7.16 ''' this seems previously install. then I tried to upgrade the python version but it says its already upgraded to the latest

' Warning: python 3.8.5 already installed '

Apparently to use this version we need to call python 3 as "python3 " as python will work both versions without conflicts.

Finally, I tried the examples with python3 joindemo.py, python3 enginedemo.py and its works nicely.

Therefore, I am kindly requesting to simply update the example execution script as I amended in README file. this will save lot of time for someone like me. ;)

Thank you.

Regards, Safras

michele-segata commented 4 years ago

This might be a problem with your installation. Can you check the version of pip by running

pip --version

?

SafrasIqbal commented 4 years ago

yes sure.

results as below

safras@Safrass-MacBook-Pro analysis % pip --version
pip 20.2.1 from /usr/local/lib/python3.8/site-packages/pip (python 3.8)

when I run with : python3 .py works just fine no issues.

michele-segata commented 4 years ago

The problem is with your system configuration. The API works with python 2 as well. The problem is that your pip is managing packages for python 3, but in your terminal python invokes python 2, so you get the ImportError: No module named plexe error. Pip installed the API for python 3 and then your system by default calls python 2. Given that python 2 is supported by the API, I am not going to merge this PR.