Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Newbie first problem
#1
Hi there.

I've just started my first book for Python "Python Crash Course" and I faced my first problem.
I believe I installed Python correctly version 3.10, because cmd is recognizing Python command.

For example when I write

print ("Hello world!") - in cmd I am receiving Hello world! below.

When I use Sublime text and I wrote same thing I am having this:

[WinError 2] The system cannot find the file specified
[cmd: ['python3', '-u', 'C:\\Users\\Chris\\Desktop\\python_work\\hello_world.py']]
[dir: C:\Users\Chris\Desktop\python_work]
[path: C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\Intel® Management Engine Components\DAL;C:\Program Files\Intel\Intel® Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel® Management Engine Components\IPT;C:\Program Files\Intel\Intel® Management Engine Components\IPT;C:\Program Files\Calibre2\;C:\Users\Chris\AppData\Local\Programs\Python\Python310\Scripts\;C:\Users\Chris\AppData\Local\Programs\Python\Python310\]
[Finished]

I created just a Python folder on my desktop and I saved the file as hello_world nothing else and it doesn't work.

Any help would be appreciated.

Thank you.
Reply
#2
Some things have to be clarified. You say you type print ("Hello world!") in cmd. I think you mean you started cmd.exe and from there started python.exe. Or python3.exe? It should somewhat look like this (I am on Linux and have a different version so there are little differences.)
$ python3
Python 3.8.10 (default, Nov 26 2021, 20:14:08) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print("Hello world!")
Hello world!
>>> exit()
$
On Linux the Python executable is usually called "python3", but I thought on Windows it was usually called "python"(.exe). So which one is it? In your error message I see:
Error:
[cmd: ['python3', '-u', 'C:\\Users\\Chris\\Desktop\\python_work\\hello_world.py']]
Apparently Sublime text assumes here the executable is "python3". Is that correct? What are the *.exe files in "C:\Users\Chris\AppData\Local\Programs\Python\Python310\"? (I assume that is where you installed Python.)


P.S.: Please read BBcode to see how to post code and error messages and output.
cima_hurdle likes this post
Reply
#3
Change to python there is no python3.exe in Python 3.10 on Windows.
Reply
#4
(Feb-07-2022, 06:39 PM)ibreeden Wrote: Some things have to be clarified. You say you type print ("Hello world!") in cmd. I think you mean you started cmd.exe and from there started python.exe. Or python3.exe? It should somewhat look like this (I am on Linux and have a different version so there are little differences.)
$ python3
Python 3.8.10 (default, Nov 26 2021, 20:14:08) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> print("Hello world!")
Hello world!
>>> exit()
$
On Linux the Python executable is usually called "python3", but I thought on Windows it was usually called "python"(.exe). So which one is it? In your error message I see:
Error:
[cmd: ['python3', '-u', 'C:\\Users\\Chris\\Desktop\\python_work\\hello_world.py']]
Apparently Sublime text assumes here the executable is "python3". Is that correct? What are the *.exe files in "C:\Users\Chris\AppData\Local\Programs\Python\Python310\"? (I assume that is where you installed Python.)


P.S.: Please read BBcode to see how to post code and error messages and output.


If I go Tools>Build System>Automatic or Python

I have just this:

[Finished in 156ms]
Reply
#5
i believe I have both Python and Python3.

At the book which I am reading say Go to Tools>Build Systrem>New Build System, delete what you see and enter:
{
"cmd": ["python3", "-u", "$file"],
}

And that is what I did, so when I go to Tools>Build Systrem I have in the list both Python and Python3.
Reply
#6
Open cmd and type this.
If it work it will look this:
C:\Users\Tom>python --version
Python 3.10.0

C:\Users\Tom>pip --version
pip 21.3.1 from C:\python310\lib\site-packages\pip (python 3.10)

# The path to python.exe
C:\Users\Tom>python -c "import sys; print(sys.executable)"
C:\python310\python.exe

# Test python3
C:\Users\Tom>python3 --version
Python was not found .....

# Use py to list all version found
C:\Users\Tom>py -0
Installed Pythons found by py Launcher for Windows
 -3.10-64 *
 -3.9-64
 -3.7-32
 -3.6-32
 -3.4-32
 -2.7-32
Then change to:
{
"cmd": ["python", "-u", "$file"],
}
The book Author use Linux that why he use Python3.
You don't have to use Sublime text(not all free) even if Author of book use it,
i would say that VS Code(all free) or easy to use PyScripter are better choices.
Reply
#7
(Feb-07-2022, 08:37 PM)snippsat Wrote: Open cmd and type this.
If it work it will look this:
C:\Users\Tom>python --version
Python 3.10.0

C:\Users\Tom>pip --version
pip 21.3.1 from C:\python310\lib\site-packages\pip (python 3.10)

# The path to python.exe
C:\Users\Tom>python -c "import sys; print(sys.executable)"
C:\python310\python.exe

# Test python3
C:\Users\Tom>python3 --version
Python was not found .....

# Use py to list all version found
C:\Users\Tom>py -0
Installed Pythons found by py Launcher for Windows
 -3.10-64 *
 -3.9-64
 -3.7-32
 -3.6-32
 -3.4-32
 -2.7-32
Then change to:
{
"cmd": ["python", "-u", "$file"],
}
The book Author use Linux that why he use Python3.
You don't have to use Sublime text(not all free) even if Author of book use it,
i would say that VS Code(all free) or easy to use PyScripter are better choices.

Sorry, I didn't get what I need to type in cmd?
I will try the other text editors, but a friend recommend me VSC and it looks quite complicated for me.
Reply
#8
(Feb-07-2022, 10:04 PM)cima_hurdle Wrote: Sorry, I didn't get what I need to type in cmd?
The code you see is just a plain copy of what i have typed in cmd,
so you just type the same.

First part will be different for you command are what's after >
python --version
ect...
Reply
#9
Thank you very much everyone!

I sort it.

I built a new system with:

{
//"shell_cmd": "make"
"cmd": ["C:\\Python\\Python.exe", "-u", "$file"],
"file_regex": "^[ ]File \"(...?)\", line ([0-9]*)",
"selector": "source.python"
}

And now is recognising the python on my hdd.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  very newbie problem on text file zapad 2 231 Apr-12-2024, 06:50 PM
Last Post: zapad
  Newbie lists problem LedDiode 5 3,670 Dec-16-2018, 08:33 PM
Last Post: LedDiode
  Newbie Ubuntu script problem Kloontor 6 3,549 Sep-24-2018, 03:51 PM
Last Post: Kloontor
  Hey guys, help a newbie out with a list problem. sdezigner 2 2,681 Feb-15-2018, 06:06 PM
Last Post: sdezigner
  newbie problem Pedroski55 3 4,503 Jul-04-2017, 07:31 AM
Last Post: buran

Forum Jump:

User Panel Messages

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