Python Forum
[Error 2] running from cmd win 10 fresh install
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Error 2] running from cmd win 10 fresh install
#1
Hi there and thank you for looking. I am very much a novice and believe Python would be an ideal language to start with due to the simplicity of the syntax. Unfortunately I have hit a road block right away.


I am using a tutorial that is a few years old that used python 3.5.1 I installed 3.6.0 as from what I could see there should be no major issues. I downloaded the x86-64 installer from the official Python website and when installing made sure to have that PATHING is selected and left the location as default (this is in appdata and not c:\(LOCATION) like all tutorials suggest). The tutorial asks me to make a text doc and type:
print(“Hello World”)
then save the text doc (filename=hello)with .py as the end of the file name. Then run cmd console type
python
this returns the version etc
I exit that and now am to run the hello.py the folder location is (I have tried Desktop and other locations all seem to fail) on C:\PythonPractice (I removed the space in an attempt to solve the problem, no luck)
I do this by either cd.. to reach c and then cd pythonpractice to enter the folder.
Then type
py hello.py
and it returns
c:\”PATH”\python.exe: can't open file “hello.py”: [Error 2] No such file or directory


I have tried uninstalling and reinstalling, changed the location of python from Appdata to c:\ and looked online and found nobody else who has had this issue yet alone a solution. I am at a complete loss and I worry that if the basics are so difficult then maybe this is not a suitable language for learning like I thought?


Would very much appreciate a solution to this and thank you very much for reading.
Reply
#2
I really wish Python would make the default location "C:\Python36" it would make life so much simpler. 

Any who,  a couple of things.  When you save a file, such as your "hello.py", it will be saved in your current directory (unless you specifically tell it different), so if you are in "C:\ " that is where it will be saved. If you are currently in "C:\PythonPractice" that is where it will be saved.  If you can't remember where it was saved, use the File Manager and search for "hello.py" (no doubt there will only be one listing :-) ). Now you have a choice, run it from it's current location or move it to your PythonPractice folder.  In either case, once you open your cmd window, you need to change to that directory, for example, from the command line, type:
cd c:\pythonpractice    # note that Windows is not case sensative but the *nix's are
Now that you are in the correct folder, simply type "hello.py" (w/o quotes).

In short, do not use "py hello.py", just "hello.py"
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply
#3
Follow my advice in this post.
Reply
#4
Quote:I really wish Python would make the default location "C:\Python36" it would make life so much simpler. 
Yeah that was a dumb decision on their part. What makes it even worse is by default windows doesnt allow a user to view the appdata directory. So that adds one more damn step to the process.
Recommended Tutorials:
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  error "cannot identify image file" part way through running hatflyer 0 612 Nov-02-2023, 11:45 PM
Last Post: hatflyer
  Install error middlestudent 1 711 Sep-23-2023, 08:26 AM
Last Post: middlestudent
  Error when running kivy on python janeik 8 1,921 Jun-16-2023, 10:58 PM
Last Post: janeik
  wxPython install error carlomscalisi 3 3,545 Jan-17-2023, 11:04 AM
Last Post: snippsat
  Getting error when running "MINUS" between 2 databases marlonbown 4 1,217 Nov-10-2022, 05:49 AM
Last Post: deanhystad
  Error with pip install coffeeguy 1 2,207 Sep-08-2022, 01:27 AM
Last Post: snippsat
  Error while running code on VSC maiya 4 3,541 Jul-01-2022, 02:51 PM
Last Post: maiya
  Pandas - error when running Pycharm, but works on cmd line zxcv101 1 1,320 Jun-18-2022, 01:09 PM
Last Post: snippsat
  kmeans install error (please help me) muratuzun 3 5,330 May-06-2022, 02:14 PM
Last Post: snippsat
  Error when running a matplot lib example aurelius_nero 3 6,686 Apr-24-2022, 01:24 PM
Last Post: Axel_Erfurt

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020