I am new to using the shell, and wanted to create a directory in $HOME
where I can put all my python scripts, set a path to that directory, so that I can go into any folder on my Mac and execute those scripts on certain files, without the script having to be contained inside the same directory as the file that would serve as the input to those scripts.
I have read around and added this to my .zshrc
file:
export PATH="$HOME/python_functions/bin:$PATH"
Then I added a script called sleep_plotter.py
to python_functions/bin
, which is where I am planning to put all my future scripts as well.
However, when I navigate to the folder that contains the text file I want to use as input to that script, and type python sleep_plotter.py 113testCtM113.txt
, the last argument being the text file input to my script, I get the following error message:
python: can't open file 'sleep_plotter.py': [Errno 2] No such file or directory
But when I call the path using echo $PATH
, I see this:
/Users/myname/python_functions/bin:
From this, I gathered that python is looking in that directory when I execute a Python command, so it should be able to run sleep_plotter.py
even when I am in a different folder that doesn't contain this file.
I am using Mac OSX 10.11.2, zsh, and Anaconda 2.3.0.