Python Forum
Newbie first problem - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Newbie first problem (/thread-36321.html)



Newbie first problem - cima_hurdle - Feb-07-2022

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.


RE: Newbie first problem - ibreeden - Feb-07-2022

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.


RE: Newbie first problem - snippsat - Feb-07-2022

Change to python there is no python3.exe in Python 3.10 on Windows.


RE: Newbie first problem - cima_hurdle - Feb-07-2022

(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]


RE: Newbie first problem - cima_hurdle - Feb-07-2022

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.


RE: Newbie first problem - snippsat - Feb-07-2022

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.


RE: Newbie first problem - cima_hurdle - Feb-07-2022

(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.


RE: Newbie first problem - snippsat - Feb-07-2022

(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...



RE: Newbie first problem - cima_hurdle - Feb-09-2022

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.