sid5432 / pyOTDR

Simple OTDR SOR file parser written in Python
GNU General Public License v3.0
71 stars 28 forks source link

Cannot open .sor file #41

Closed pgm00039 closed 2 years ago

pgm00039 commented 2 years ago

Hi! Due to work issues I'm learning to use Python. I have installed pyotdr as you wrote on the main page. However, I can't parse any file as you say here: "To parse an OTDR SOR file, run the program as pyotdr myfile.sor" The console show me an error -> ### SyntaxError: invalid syntax Could you tell me how I could make correct use of it?

RemiDesgrange commented 2 years ago
pgm00039 commented 2 years ago

Yes, I'm writing that command but I don't know if I'm using it wrong

I'm using Windows 10 and Python 3.9 (Spyder) via Anaconda

RemiDesgrange commented 2 years ago

I don't have any Windows machine to test. I can confirm that pyOTDR is working with python 3.9. Can you paste the entire stack trace (error) showed on your terminal.

pgm00039 commented 2 years ago

runfile('C:/Users/Pablo/Desktop/prueba/untitled0.py', wdir='C:/Users/Pablo/Desktop/prueba') File "C:\Users\Pablo\Desktop\prueba\untitled0.py", line 3 pyOTDR myfile.sor ^ SyntaxError: invalid syntax

RemiDesgrange commented 2 years ago

I think you are trying to run it inside a python terminal? You have to run it inside a shell terminal, not python interpreter

pgm00039 commented 2 years ago

I have tried both but to no avail. I get the same result.

sid5432 commented 2 years ago

I tried this on a Win10 laptop running Python 3.7 (pip install pyotdr, then run the pyotdr command), but cannot reproduce the problem. I know that you have already tried running this outside the python interpreter, but have a look at this:

https://stackoverflow.com/questions/13961140/syntax-error-when-using-command-line-in-python

Does just typing python.exe in the CMD window work for you?

pgm00039 commented 2 years ago

Yes, I also tried in the CMD but I get the same issue with SyntaxError: invalid syntax

sid5432 commented 2 years ago

I just noticed you have a "untitled0.py" file in your error listing. Is this a python file you created? Did you put in the line

pyotdr myfile.sor

inside a python file, and are trying to run the "untitled0.py" file?

pgm00039 commented 2 years ago

Yes, I tried in many ways, but none of them worked for me. I really need to be able to use it as part of my college final project. I need to be able to use it to analyze the trace.

sid5432 commented 2 years ago

You said "yes"; does this mean that you do have the line

pyotdr myfile.sor

inside a python file "untitled0.py"?

You should not be doing that. You need to type this on the command line (next to the C:> prompt); it should look something like this:

C:/> pyotdr myfile.sor

This is outside of python. Not in a python interpreter window, or having that line inside a python file and trying to execute that python file. If you want to integrate pyotdr inside your program, that is a different matter altogether.