Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

print("Hello, wesley")

it keeps saying bash error

1 Answer

Jeff Muday
MOD
Jeff Muday
Treehouse Moderator 28,720 Points

If you make the FIRST line of a python program file a "shebang" and the path to the python interpreter, it will work in Bash. (this will not work on the Windows OS)

The "shebang" is known to Linux users as the # followed by ! and the path to the Python interpreter is /usr/local/bin/python

One additional step is to make the file executable by typing the command chmod +x wesley.py

I hope this helps you out!

treehouse:~/workspace$ cat wesley.py
#!/usr/local/bin/python                                                                   
print("Hello, wesley") 

treehouse:~/workspace$ python wesley.py                                                                
Hello, wesley 

treehouse:~/workspace$ which python                                                                    
/usr/local/bin/python 

treehouse:~/workspace$ wesley.py                                                                       
bash: wesley.py: command not found

treehouse:~/workspace$ ./wesley.py                                                                     
bash: ./wesley.py: Permission denied 

treehouse:~/workspace$ chmod +x wesley.py                                                              
treehouse:~/workspace$ ./wesley.py                                                                     
Hello, wesley                                                                                          

it doesn't work please