-1

I get a message saying Python was not found.

This is a part of my code

parser = OptionParser()
parser.add_option('-u', action="store")
parser.add_option('-d', action="store")
parser.add_option('-t', action="store")
options, args = parser.parse_args()

readerID = str(options.u)
docID = str(options.d)
task_selection = str(options.t)

if task_selection == '2a':
    print("Countries of Visitors:")
    for k,v in (Counter(program.ViewByCountry(docID,task_selection))).items():
        print(k,"-->",v)
elif task_selection == '2b':
    print("Continents of Visitors:")
    for k,v in (Counter(program.ViewByCountry(docID,task_selection))).items():
        print (k,"-->",v)

This is my task.

Provide a command-line interface to test your program like this :

% cw2 -u user_uuid -d doc_uuid -t task_id -f file_name

When I put this in my command line :

python3 cw2.py -d 140218233015-c848da298ed6d38b98e18a85731a83f4 -t 3a

I get a message saying Python was not found. I have created this in Pycharm. Why does this happen?

bad_coder
  • 11,289
  • 20
  • 44
  • 72
user17534067
  • 1
  • 1
  • 5
  • 3
    Show the _exact_ error message, not just a summary of its text. – Charles Duffy Nov 29 '21 at 20:45
  • If it's saying that `python3` isn't in your path, that's something we need to know. – Charles Duffy Nov 29 '21 at 20:46
  • (also, what platform are you on? If this is Windows, then instead of `python3`, you might need to run `py -3`). – Charles Duffy Nov 29 '21 at 20:46
  • I created my program in pycharm. I don't get the error message now. I installed python and now I get SyntaxError: invalid syntax >>> python3 cw2.py -t 4 File "", line 1 python3 cw2.py -t 4 ^ SyntaxError: invalid syntax – user17534067 Nov 29 '21 at 21:17
  • That's because you need to run it at a _shell_ prompt, but you're instead running it at a _Python_ prompt. – Charles Duffy Nov 29 '21 at 21:27
  • cmd right? I tried it through cmd – user17534067 Nov 29 '21 at 21:32
  • I think this is a duplicate of https://stackoverflow.com/q/65348890 – bad_coder Nov 29 '21 at 22:53
  • 1
    Does this answer your question? [Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings](https://stackoverflow.com/questions/65348890/python-was-not-found-run-without-arguments-to-install-from-the-microsoft-store) – bad_coder Nov 30 '21 at 01:23

1 Answers1

1

You probably haven't added python to path. This question is most probably a duplicate you might want to search stackoverflow before asking a new question later on.

first press windows key and search python.

then right-click on python and choose open containing folder

from there copy the address of python.exe executable

add the copied address to path

To add to path: https://helpdeskgeek.com/windows-10/add-windows-path-environment-variable/

PS: i dont think you need to specify the '3' at the end of the command (eg: python3) that is usually for linux users on windows just make sure you have the latest version and type:

python *filename* [flags]

hirad davari
  • 103
  • 6
  • Python-on-Windows has a `py` launcher that's the official Right Way to find the correct Python executable, even if multiple interpreters are installed (it's common to have both a Python 3 interpreter and a Python 2 interpreter so one can work on projects targeting both major revisions of the language). This answer would be stronger if it described how to use it. – Charles Duffy Nov 29 '21 at 20:47