我如何修改我的.bash_profile文件,以便在不输入文件路径的情况下运行我的python脚本?



我是OSX新手,熟悉这个环境下的文件结构。我的.bash_profile文件如下所示:

# 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

我的脚本在几个目录中,例如:

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

我想做的是打开我的终端,输入脚本的名称(例如myscript.py),然后执行,就像在windows环境中通过指定*.py文件与Python的关联所做的那样。

有没有人可以帮我用mac完成这个?

谢谢

试着把它放在您的.bash_profile中:

# 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

基本上,你把包含你想要的可执行文件的目录,用':'分隔

最新更新