What python are you aiming for?
Did you install this with brew? He uses a different way.
which python3 or which python
Choose the one you want
Copy this output
Paste it at the top of your Python file
add #! before this path so it looks like
#!/usr/local/bin/python3
Be sure to change file permissions
chmod +x filename
Put this file in a folder that is in your path
Not sure if your folder is in your path?
echo $path
How to add this folder to your path?
Find your way first
echo $HOME
If you use bash or zsh, you might have something like this
In ~/.bash_profile or ~/.bashrc or ~/.zshrc at the bottom of your file
export PYTHON_UTILS="$HOME/code/python/utils"
export PATH="$PYTHON_UTILS:$PATH"
Consider removing .py from your file, as he is not needed in this case
Close and open your terminal, which receives your file by its path
And now you should be able to process your python file similarly to the bash command.
You do not need to use python3 filename.py to run the file, you can just use filename
From anywhere in your file system!
jasonleonhard
source share