Luis Miguel
Luis Miguel

Reputation: 5137

How can I modify my .bash_profile file so I can run my python scripts w/o typing the path to the file?

I am new with OSX and getting familiar with file structures in this environment. My .bash_profile file looks like this:

# Setting PATH for EPD_free-7.3-2
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:${PATH}"
export PATH

My scripts are in several directories, for example:

/Users/LMS/Documents/pydata-book
/Users/LMS/Documents/python_scripts

What I would like to do is open my terminal, type the name of the script (for example myscript.py), and be executed, just like one would do by specifying an association of *.py files with Python, in a windows environment.

Anybody out there could help me accomplish this with a mac?

Thanks

Upvotes: 1

Views: 1786

Answers (1)

KaeruCT
KaeruCT

Reputation: 1645

Try putting this in your .bash_profile instead:

# Setting PATH for EPD_free-7.3-2
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:/Users/LMS/Documents/pydata-book:/Users/LMS/Documents/python_scripts:${PATH}"

export PATH

Basically, you put the directories that contain the executable files you want, separated by ':'

Upvotes: 3

Related Questions