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

StackOverflow https://stackoverflow.com/questions/14140766

  •  12-01-2022
  •  | 
  •  

Question

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

Was it helpful?

Solution

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 ':'

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top