Comments (9)
I'm glad we got that sorted. :)
I see numbers
in there. There's a module in the Python standard library named numbers.py
. If you end up needing that module, or using a library that depends on that module, this can cause some bugs that can be hard to sort out. You might consider renaming that file.
I'll admit I had a file called numbers.py in the first edition of PCC, and it caused some issues for some readers. 🤦
from pcc_3e.
Thank you for letting me know. I believe your system recognizes .py files as executable files, and knows where to find the Python interpreter when it needs to run a .py file.
from pcc_3e.
Yes, was a little bit frustrating when I can’t even execute the first “Hello world” assignment. Almost grabbed me a book of py for dummies. This is for those who shall share my similar faith and to never give up 😁
Thank you for responding Eric.
from pcc_3e.
Are you saying this worked:
> hello_world
But this did not:
> python hello_world.py
Or was it this?
> python hello_world
from pcc_3e.
The second one.
python hello_world
from pcc_3e.
Okay, that's interesting. Are you sure you saved your file as hello_world.py
, and not hello_world
?
For a simple script like hello world, the .py extension isn't always needed:
~/test_code/py_ext_tester$ ls -alh
-rw-r--r-- 1 eric staff 23B May 3 08:31 hello
-rw-r--r-- 1 eric staff 23B May 3 08:31 hello.py
-rw-r--r-- 1 eric staff 23B May 3 08:34 hello.txt
~/test_code/py_ext_tester$ python hello.py
Hello world!
~/test_code/py_ext_tester$ python hello.txt
Hello world!
~/test_code/py_ext_tester$ python hello
Hello world!
This example is on macOS, but the same thing should apply to Windows.
It gets confusing because file browsers such as Windows Explorer used to show all file extensions by default. Now they tend to hide extensions unless you configure them to show all extensions. So you might see hello_world
in Explorer, but it might actually be hello_world.py
. Even more confusing, people will sometimes see hello_world.py
in Explorer, when the file is actually named hello_world.py.py
!
You can check the filename definitively in the terminal with the dir
command. Can you run dir
in the directory where your hello world file is saved, and share the output?
from pcc_3e.
That is a good point. I’ll check the file name when i get home later and share the output. I remember saving it as hello_world.py from the vs window though it dropped the .py when it went windows to save as i recall but i did not put much thought to that as my default does not show the file extensions.
from pcc_3e.
C:\Users\marop\OneDrive\Desktop\python_work>dir
Volume in drive C is BOOTCAMP
Volume Serial Number is 0246-9FF7
Directory of C:\Users\marop\OneDrive\Desktop\python_work
05/03/2024 04:39 AM
.05/03/2024 04:39 AM ..
05/01/2024 05:15 PM .vscode
05/01/2024 09:49 PM 399 bicycles
05/03/2024 04:39 AM 1,235 Cars
05/01/2024 06:05 PM 182 hello_world
05/03/2024 05:20 AM 589 lapamilya.py
05/01/2024 06:12 PM 172 mensahe.py
05/01/2024 09:22 PM 433 name.py
05/01/2024 07:04 PM 249 name_cases.py
05/01/2024 07:10 PM 392 name_quotes
05/01/2024 09:21 PM 223 numbers
05/01/2024 09:32 PM 13 Zen_Python
10 File(s) 3,887 bytes
3 Dir(s) 422,718,844,928 bytes free
C:\Users\marop\OneDrive\Desktop\python_work>/test_code/py_ext_tester$ ls -alh' is not recognized as an internal or external command,
'
operable program or batch file.
from pcc_3e.
You're right. Apparently, I saved it as hello_world, and not hello_world.py
from pcc_3e.
Related Issues (9)
- Python crash course
- pathlib.Path read_text() HOT 1
- alien_invasion: Pressing Q to Quit HOT 7
- UnboundLocalError: local variable 'range' referenced before assignment HOT 3
- Matplotlib installation through pip HOT 2
- pcc_3e/chapter_11 /test_name_function.py differs from text printed in book HOT 3
- About ex_20_4_extended HOT 4
- chapter_13/ending_the_game : Ship Limit Discrepancy in Alien Invasion Game
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pcc_3e.