Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4323666
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T09:01:55+00:00 2026-05-21T09:01:55+00:00

Massive apologies for this embarrassing question— I’m using my MacBook Pro, running snow leopard,

  • 0

Massive apologies for this embarrassing question—

I’m using my MacBook Pro, running snow leopard, and using Python 2.7.1. Trying to run my first script and all the first pages of all my tutorials are laughing at me:

Let me preface with:

$ whereis python  
/usr/bin/python  
$ which python
/Library/Frameworks/Python.framework/Versions/2.7/bin/python

(Is this my issue?)

I wrote helloworld.py to /users/charles in vim:

$ vim helloworld.py  
#!/usr/bin/python  
# Hello World Python Program  

print "Hello World!";

When trying to run it from terminal:

$ helloworld.py
-bash: helloworld.py: command not found

When trying to run it from python:

$ python
>>> helloworld.py
Traceback (most recent call last):
  File :<stdin>", line 1, in <module>
NameError: name 'helloworld' is not defined

From Dive Into Python (not sure if this is pertinent):

$ python
>>> import sys,os
>>> print 'sys.argv[0] =',sys.argv[0]
sys.argv[0]=
>>> pathname=os.path.dirname(sys.argv[0])
>>> print 'path=',pathname
path=
>>> print 'full path=',os.path.abspath(pathname)
full path= /Users/charles

I’m befuddled! Do I need to alter one of my paths so it finds my script?

I’m absolutely new to programming, I actually just found out that terminal was something you could use.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T09:01:56+00:00Added an answer on May 21, 2026 at 9:01 am

    To turn a Python module or script into a standalone program on a UNIX system you have to do two things:

    1.) Make sure you have the “shebang” in the top of your script:

    #!/usr/bin/python
    

    2.) Make sure the script file is executable. This is done using the chmod command:

    chmod +x /path/to/helloworld.py
    

    /path/to/ being the fully qualified file path to your script. If it’s in the current directory, then you can omit the path.

    % ls -l
    total 0
    drwxr-xr-x  2 jathan jathan   60 2011-04-13 15:28 ./
    drwxrwxrwt 12 root   root   6.5K 2011-04-13 15:28 ../
    -rw-r--r--  1 jathan jathan    0 2011-04-13 15:28 helloworld.py
    

    It’s in my current directory, so let’s make it executable!

    % chmod +x helloworld.py 
    % ls -l                 
    drwxr-xr-x  2 jathan jathan   60 2011-04-13 15:28 ./
    drwxrwxrwt 12 root   root   6.5K 2011-04-13 15:28 ../
    -rwxr-xr-x  1 jathan jathan    0 2011-04-13 15:28 helloworld.py*
    

    See the “x”s in the permission bits on the left? You’ve done it! Now we can run it:

    % ./helloworld.py   
    Hello World!
    

    Lastly, never use semicolons as line-endings in Python. It’s not required and it’s ugly!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're going through a massive migration project at the minute and trying to validate
I apologize for the subjectiveness of this question, but I am a little stuck
I was wondering whether the instant search using jQuery would cause a massive load
hiya i have a massive job trying to sort thousands of records all is
I'm trying to parse a massive xml file into my MySQL database. the file
Update 25/03/2011 I've marked this question as answered, while I don't yet have the
I've begun using Massive, by Rob Conery. Awesome little ORM and very performant. However,
I'm using Rob Conery's Massive ORM, and I haven't been able to bind the
Here on this page, Scott Hanselman shows two examples from Micro-ORMs Dapper and Massive,
This is language agnostic (but I am using PHP and MySQL if it helps).

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.